Class: Arrolio::Content::Image

Inherits:
Object
  • Object
show all
Defined in:
lib/arrolio/content/image.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(src, width: nil, height: nil, alt: nil, style_id: :figure_image, id: nil) ⇒ Image

Returns a new instance of Image.



8
9
10
11
12
13
14
15
16
17
# File 'lib/arrolio/content/image.rb', line 8

def initialize(src, width: nil, height: nil, alt: nil,
               style_id: :figure_image, id: nil)
  @src = src.to_s
  @width = width&.to_f
  @height = height&.to_f
  @alt = alt
  @style_id = style_id.to_sym
  @id = id
  freeze
end

Instance Attribute Details

#altObject (readonly)

Returns the value of attribute alt.



6
7
8
# File 'lib/arrolio/content/image.rb', line 6

def alt
  @alt
end

#heightObject (readonly)

Returns the value of attribute height.



6
7
8
# File 'lib/arrolio/content/image.rb', line 6

def height
  @height
end

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/arrolio/content/image.rb', line 6

def id
  @id
end

#srcObject (readonly)

Returns the value of attribute src.



6
7
8
# File 'lib/arrolio/content/image.rb', line 6

def src
  @src
end

#style_idObject (readonly)

Returns the value of attribute style_id.



6
7
8
# File 'lib/arrolio/content/image.rb', line 6

def style_id
  @style_id
end

#widthObject (readonly)

Returns the value of attribute width.



6
7
8
# File 'lib/arrolio/content/image.rb', line 6

def width
  @width
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



19
20
21
22
23
24
25
26
27
# File 'lib/arrolio/content/image.rb', line 19

def ==(other)
  other.is_a?(self.class) &&
    src == other.src &&
    width == other.width &&
    height == other.height &&
    alt == other.alt &&
    style_id == other.style_id &&
    id == other.id
end

#hashObject



31
32
33
# File 'lib/arrolio/content/image.rb', line 31

def hash
  [self.class, src, width, height, alt, style_id, id].hash
end