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.



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

#sizeObject (readonly)

Returns the value of attribute size.



10
11
12
# File 'lib/link_thumbnailer/models/image.rb', line 10

def size
  @size
end

#srcObject (readonly)

Returns the value of attribute src.



10
11
12
# File 'lib/link_thumbnailer/models/image.rb', line 10

def src
  @src
end

#typeObject (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_jsonObject



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_sObject



18
19
20
# File 'lib/link_thumbnailer/models/image.rb', line 18

def to_s
  src.to_s
end

#valid?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/link_thumbnailer/models/image.rb', line 26

def valid?
  validator.call
end