Class: Arrolio::Content::Section
- Inherits:
-
Object
- Object
- Arrolio::Content::Section
- Defined in:
- lib/arrolio/content/section.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#level ⇒ Object
readonly
Returns the value of attribute level.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#style_id ⇒ Object
readonly
Returns the value of attribute style_id.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#title_style_id ⇒ Object
readonly
Returns the value of attribute title_style_id.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
- #heading? ⇒ Boolean
-
#initialize(title: nil, level: 1, number: nil, id: nil, children: [], style_id: :section_body, title_style_id: nil) ⇒ Section
constructor
A new instance of Section.
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
#children ⇒ Object (readonly)
Returns the value of attribute children.
6 7 8 |
# File 'lib/arrolio/content/section.rb', line 6 def children @children end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/arrolio/content/section.rb', line 6 def id @id end |
#level ⇒ Object (readonly)
Returns the value of attribute level.
6 7 8 |
# File 'lib/arrolio/content/section.rb', line 6 def level @level end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
6 7 8 |
# File 'lib/arrolio/content/section.rb', line 6 def number @number end |
#style_id ⇒ Object (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 |
#title ⇒ Object (readonly)
Returns the value of attribute title.
6 7 8 |
# File 'lib/arrolio/content/section.rb', line 6 def title @title end |
#title_style_id ⇒ Object (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 |
#hash ⇒ Object
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
20 |
# File 'lib/arrolio/content/section.rb', line 20 def heading? = !@title.nil? |