Class: OpenStax::Utilities::Blocks::SectionBlock
- Defined in:
- lib/openstax/utilities/blocks/section_block.rb
Instance Attribute Summary collapse
-
#heading ⇒ Object
Returns the value of attribute heading.
-
#nesting ⇒ Object
Returns the value of attribute nesting.
-
#top_bar ⇒ Object
Returns the value of attribute top_bar.
Attributes inherited from BlockBase
Instance Method Summary collapse
-
#initialize(template, heading, block) ⇒ SectionBlock
constructor
A new instance of SectionBlock.
- #set_heading(string) ⇒ Object
- #set_nesting(depth) ⇒ Object
- #set_top_bar ⇒ Object
- #show_heading? ⇒ Boolean
Methods inherited from BlockBase
Constructor Details
#initialize(template, heading, block) ⇒ SectionBlock
Returns a new instance of SectionBlock.
15 16 17 18 19 20 21 22 |
# File 'lib/openstax/utilities/blocks/section_block.rb', line 15 def initialize(template, heading, block) super(template, "section", block) set_heading(heading) if !heading.blank? section_class_add "section-block-section" heading_class_add "section-block-heading" body_class_add "section-block-body" end |
Instance Attribute Details
#heading ⇒ Object
Returns the value of attribute heading.
11 12 13 |
# File 'lib/openstax/utilities/blocks/section_block.rb', line 11 def heading @heading end |
#nesting ⇒ Object
Returns the value of attribute nesting.
12 13 14 |
# File 'lib/openstax/utilities/blocks/section_block.rb', line 12 def nesting @nesting end |
#top_bar ⇒ Object
Returns the value of attribute top_bar.
13 14 15 |
# File 'lib/openstax/utilities/blocks/section_block.rb', line 13 def @top_bar end |
Instance Method Details
#set_heading(string) ⇒ Object
24 25 26 27 |
# File 'lib/openstax/utilities/blocks/section_block.rb', line 24 def set_heading(string) self.heading = string self end |
#set_nesting(depth) ⇒ Object
29 30 31 32 |
# File 'lib/openstax/utilities/blocks/section_block.rb', line 29 def set_nesting(depth) self.nesting = depth self end |
#set_top_bar ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/openstax/utilities/blocks/section_block.rb', line 34 def raise "SectionBlock top bar cannot be changed once initialized" \ if @top_bar section_class_add "bar-top" self. = true self end |
#show_heading? ⇒ Boolean
55 56 57 |
# File 'lib/openstax/utilities/blocks/section_block.rb', line 55 def show_heading? heading.present? end |