class Flickr::Object::Photo::Size
Encapsulates the logic of managing sizes, including comparison, to make it easier to add dynamic size-changing methods to Flickr::Object::Photo
.
@private
Constants
Attributes
name[R]
Public Class Methods
all()
click to toggle source
# File lib/flickr/object/photo/size.rb, line 38 def self.all NAMES.map { |name| new(name) } end
exists?(name)
click to toggle source
# File lib/flickr/object/photo/size.rb, line 46 def self.exists?(name) all.include? new(name) end
new(name)
click to toggle source
# File lib/flickr/object/photo/size.rb, line 52 def initialize(name) @name = name end
types()
click to toggle source
# File lib/flickr/object/photo/size.rb, line 42 def self.types all.map(&:type).uniq end
Public Instance Methods
<=>(other)
click to toggle source
{NAMES} orders the sizes from smallest to largest, so we’re using that here.
# File lib/flickr/object/photo/size.rb, line 80 def <=>(other) NAMES.index(self.name) <=> NAMES.index(other.name) end
abbreviation()
click to toggle source
# File lib/flickr/object/photo/size.rb, line 64 def abbreviation ABBREVIATIONS[NAMES.index(name)] end
label()
click to toggle source
# File lib/flickr/object/photo/size.rb, line 72 def label LABELS[NAMES.index(name)] end
number()
click to toggle source
# File lib/flickr/object/photo/size.rb, line 60 def number name.split[1] end
other_abbreviation()
click to toggle source
# File lib/flickr/object/photo/size.rb, line 68 def other_abbreviation OTHER_ABBREVIATIONS[NAMES.index(name)] end
type()
click to toggle source
# File lib/flickr/object/photo/size.rb, line 56 def type name.split[0] end