Class: LinkThumbnailer::Models::Image

Inherits:
LinkThumbnailer::Model show all
Defined in:
lib/link_thumbnailer/models/image.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from LinkThumbnailer::Model

#to_json

Constructor Details

#initialize(src, size = nil, type = nil) ⇒ Image

Returns a new instance of Image.



14
15
16
17
18
# File 'lib/link_thumbnailer/models/image.rb', line 14

def initialize(src, size = nil, type = nil)
  @src  = src
  @size = size || parser.size
  @type = type || parser.type
end

Instance Attribute Details

#sizeObject (readonly)

Returns the value of attribute size.



12
13
14
# File 'lib/link_thumbnailer/models/image.rb', line 12

def size
  @size
end

#srcObject (readonly)

Returns the value of attribute src.



12
13
14
# File 'lib/link_thumbnailer/models/image.rb', line 12

def src
  @src
end

#typeObject (readonly)

Returns the value of attribute type.



12
13
14
# File 'lib/link_thumbnailer/models/image.rb', line 12

def type
  @type
end

Instance Method Details

#<=>(other) ⇒ Object



24
25
26
# File 'lib/link_thumbnailer/models/image.rb', line 24

def <=>(other)
  comparator.call(other)
end

#as_jsonObject



32
33
34
35
36
37
38
# File 'lib/link_thumbnailer/models/image.rb', line 32

def as_json(*)
  {
    src:  src.to_s,
    size: size,
    type: type
  }
end

#to_sObject



20
21
22
# File 'lib/link_thumbnailer/models/image.rb', line 20

def to_s
  src.to_s
end

#valid?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/link_thumbnailer/models/image.rb', line 28

def valid?
  validator.call
end