Class: OpenStax::Utilities::Blocks::SectionBlock

Inherits:
BlockBase
  • Object
show all
Defined in:
lib/openstax/utilities/blocks/section_block.rb

Instance Attribute Summary collapse

Attributes inherited from BlockBase

#captured_block

Instance Method Summary collapse

Methods inherited from BlockBase

#to_s

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

#headingObject

Returns the value of attribute heading.



11
12
13
# File 'lib/openstax/utilities/blocks/section_block.rb', line 11

def heading
  @heading
end

#nestingObject

Returns the value of attribute nesting.



12
13
14
# File 'lib/openstax/utilities/blocks/section_block.rb', line 12

def nesting
  @nesting
end

#top_barObject

Returns the value of attribute top_bar.



13
14
15
# File 'lib/openstax/utilities/blocks/section_block.rb', line 13

def top_bar
  @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_barObject



34
35
36
37
38
39
40
# File 'lib/openstax/utilities/blocks/section_block.rb', line 34

def set_top_bar
  raise "SectionBlock top bar cannot be changed once initialized" \
    if @top_bar
  section_class_add "bar-top"
  self.top_bar = true
  self
end

#show_heading?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/openstax/utilities/blocks/section_block.rb', line 55

def show_heading?
  heading.present?
end