Class: JekyllSupport::Section

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(outline_options, parameter_array) ⇒ Section

Returns a new instance of Section.



7
8
9
10
11
12
# File 'lib/structure/section.rb', line 7

def initialize(outline_options, parameter_array)
  @outline_options = outline_options
  @order = parameter_array[0].to_i
  @title = parameter_array[1]
  @children = []
end

Instance Attribute Details

#childrenObject

Returns the value of attribute children.



5
6
7
# File 'lib/structure/section.rb', line 5

def children
  @children
end

#orderObject

Returns the value of attribute order.



5
6
7
# File 'lib/structure/section.rb', line 5

def order
  @order
end

#titleObject

Returns the value of attribute title.



5
6
7
# File 'lib/structure/section.rb', line 5

def title
  @title
end

Instance Method Details

#add_child(child) ⇒ Object



14
15
16
# File 'lib/structure/section.rb', line 14

def add_child(child)
  @children << child
end

#to_sObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/structure/section.rb', line 18

def to_s
  return '' if @children.count.zero?

  unless @children.first.instance_of?(JekyllSupport::APage)
    raise "First child of Section was a #{@children.first.class}, not an APage"
  end
  apages = @children
           .map { |x| x.render_outline_apage @outline_options.pattern }
           .join("\n      ")

  "    <h3 class='post_title clear' id=\"title_\#{@order}\">\#{@title}</h3>\n      <div id='posts_wrapper_\#{@order}' class='clearfix'>\n        <div id=\"posts_\#{@order}\" class='posts'>\n          \#{apages}\n        </div>\n      </div>\n  END_SECTION\nend\n"