Class: LinkThumbnailer::Models::Image
- Inherits:
-
LinkThumbnailer::Model
- Object
- LinkThumbnailer::Model
- LinkThumbnailer::Models::Image
- Defined in:
- lib/link_thumbnailer/models/image.rb
Instance Attribute Summary collapse
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#src ⇒ Object
readonly
Returns the value of attribute src.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #as_json ⇒ Object
-
#initialize(src, size = nil, type = nil) ⇒ Image
constructor
A new instance of Image.
- #to_s ⇒ Object
- #valid? ⇒ Boolean
Methods inherited from LinkThumbnailer::Model
Constructor Details
#initialize(src, size = nil, type = nil) ⇒ Image
Returns a new instance of Image.
12 13 14 15 16 |
# File 'lib/link_thumbnailer/models/image.rb', line 12 def initialize(src, size = nil, type = nil) @src = src @size = size || parser.size @type = type || parser.type end |
Instance Attribute Details
#size ⇒ Object (readonly)
Returns the value of attribute size.
10 11 12 |
# File 'lib/link_thumbnailer/models/image.rb', line 10 def size @size end |
#src ⇒ Object (readonly)
Returns the value of attribute src.
10 11 12 |
# File 'lib/link_thumbnailer/models/image.rb', line 10 def src @src end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
10 11 12 |
# File 'lib/link_thumbnailer/models/image.rb', line 10 def type @type end |
Instance Method Details
#<=>(other) ⇒ Object
22 23 24 |
# File 'lib/link_thumbnailer/models/image.rb', line 22 def <=>(other) comparator.call(other) end |
#as_json ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/link_thumbnailer/models/image.rb', line 30 def as_json(*) { src: src.to_s, size: size, type: type } end |
#to_s ⇒ Object
18 19 20 |
# File 'lib/link_thumbnailer/models/image.rb', line 18 def to_s src.to_s end |
#valid? ⇒ Boolean
26 27 28 |
# File 'lib/link_thumbnailer/models/image.rb', line 26 def valid? validator.call end |