Class: Arrolio::Content::List::Item

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content, marker: nil) ⇒ Item

Returns a new instance of Item.



36
37
38
39
40
# File 'lib/arrolio/content/list.rb', line 36

def initialize(content, marker: nil)
  @content = Array(content).freeze
  @marker = marker
  freeze
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



34
35
36
# File 'lib/arrolio/content/list.rb', line 34

def content
  @content
end

#markerObject (readonly)

Returns the value of attribute marker.



34
35
36
# File 'lib/arrolio/content/list.rb', line 34

def marker
  @marker
end

Instance Method Details

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



48
49
50
# File 'lib/arrolio/content/list.rb', line 48

def ==(other)
  other.is_a?(self.class) && content == other.content && marker == other.marker
end

#hashObject



54
55
56
# File 'lib/arrolio/content/list.rb', line 54

def hash
  [self.class, content, marker].hash
end

#textObject



42
43
44
45
46
# File 'lib/arrolio/content/list.rb', line 42

def text
  @content.map do |node|
    node.is_a?(Paragraph) ? node.text : node.to_s
  end.join(' ')
end