Module: Booky::Layout::Helpers
- Included in:
- Base::Blockquote, Base::Chart, Base::Charts::Bar, Base::Charts::Base, Base::Charts::Line, Base::Code, Base::Footnote, Base::H0, Base::H1, Base::H2, Base::H3, Base::H4, Base::Image, Base::Import, Base::NumberedList, Base::Outline, Base::Table, Base::Title, Base::Toc, Base::Tof, Base::UnnumberedList
- Defined in:
- lib/booky/layout/helpers.rb
Instance Method Summary collapse
Instance Method Details
#add_to_toc(level, name = ) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/booky/layout/helpers.rb', line 13 def add_to_toc(level, name = [:text]) return unless is_first_rendering? path = Booky::Layout.config.levels.values.dup.reject{|e| e == 0} parent = [] parent = Booky::Layout.config.toc.dup.reverse.each{ |entry| break(entry[:name]) if entry[:level] == (level - 1) } if level > 1 Booky::Layout.config.toc << { :name => name, :page => page_number, :level => level, :levels => Booky::Layout.config.levels.dup, :path => path, :parent => parent } end |
#is_first_rendering? ⇒ Boolean
24 25 26 |
# File 'lib/booky/layout/helpers.rb', line 24 def is_first_rendering? Booky::Layout.config.runs == 1 end |
#update_levels(level) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/booky/layout/helpers.rb', line 4 def update_levels(level) return unless is_first_rendering? ((level+1)..Booky::Layout.config.last_level).each{ |l| Booky::Layout.config.levels[l] = 0 } if Booky::Layout.config.last_level > level Booky::Layout.config.levels[level] += 1 Booky::Layout.config.last_level = level end |