Class: Arrolio::Content::Section

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title: nil, level: 1, number: nil, id: nil, children: [], style_id: :section_body, title_style_id: nil) ⇒ Section

Returns a new instance of Section.



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

def initialize(title: nil, level: 1, number: nil, id: nil,
               children: [], style_id: :section_body, title_style_id: nil)
  @title = title
  @level = level.to_i
  @number = number
  @id = id
  @children = Array(children).freeze
  @style_id = style_id.to_sym
  @title_style_id = (title_style_id || default_title_style).to_sym
  freeze
end

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



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

def children
  @children
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#levelObject (readonly)

Returns the value of attribute level.



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

def level
  @level
end

#numberObject (readonly)

Returns the value of attribute number.



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

def number
  @number
end

#style_idObject (readonly)

Returns the value of attribute style_id.



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

def style_id
  @style_id
end

#titleObject (readonly)

Returns the value of attribute title.



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

def title
  @title
end

#title_style_idObject (readonly)

Returns the value of attribute title_style_id.



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

def title_style_id
  @title_style_id
end

Instance Method Details

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



22
23
24
25
26
27
# File 'lib/arrolio/content/section.rb', line 22

def ==(other)
  other.is_a?(self.class) &&
    title == other.title && level == other.level && number == other.number &&
    id == other.id && children == other.children &&
    style_id == other.style_id && title_style_id == other.title_style_id
end

#hashObject



30
31
32
# File 'lib/arrolio/content/section.rb', line 30

def hash
  [self.class, title, level, number, id, children, style_id, title_style_id].hash
end

#heading?Boolean

Returns:

  • (Boolean)


20
# File 'lib/arrolio/content/section.rb', line 20

def heading? = !@title.nil?