Class: Bookingit::Config
- Inherits:
-
Object
- Object
- Bookingit::Config
- Includes:
- FileUtils
- Defined in:
- lib/bookingit/config.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#back_matter ⇒ Object
readonly
Returns the value of attribute back_matter.
-
#cache ⇒ Object
Returns the value of attribute cache.
-
#front_matter ⇒ Object
readonly
Returns the value of attribute front_matter.
-
#main_matter ⇒ Object
readonly
Returns the value of attribute main_matter.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#rendering_config ⇒ Object
readonly
Returns the value of attribute rendering_config.
-
#templates ⇒ Object
readonly
Returns the value of attribute templates.
Instance Method Summary collapse
-
#initialize(config_json, root_dir) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(config_json, root_dir) ⇒ Config
Returns a new instance of Config.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/bookingit/config.rb', line 16 def initialize(config_json,root_dir) config_hash = JSON.parse(config_json) @front_matter = Matter.new(config_hash.delete('front_matter'),root_dir) @main_matter = Matter.new(config_hash.delete('main_matter'),root_dir) @back_matter = Matter.new(config_hash.delete('back_matter'),root_dir) @templates = config_hash.delete("templates") || {} @templates["index"] ||= "index.html" @rendering_config = create_rendering_config(config_hash.delete('rendering')) @cache = false = config_hash all_chapters = (@front_matter.chapters + @main_matter.chapters + @back_matter.chapters) all_chapters.each_with_index do |chapter,i| if i > 0 all_chapters[i-1].next_chapter = chapter chapter.previous_chapter = all_chapters[i-1] end if i < (all_chapters.size-1) all_chapters[i+1].previous_chapter = chapter chapter.next_chapter = all_chapters[i+1] end end end |
Instance Attribute Details
#back_matter ⇒ Object (readonly)
Returns the value of attribute back_matter.
8 9 10 |
# File 'lib/bookingit/config.rb', line 8 def back_matter @back_matter end |
#cache ⇒ Object
Returns the value of attribute cache.
8 9 10 |
# File 'lib/bookingit/config.rb', line 8 def cache @cache end |
#front_matter ⇒ Object (readonly)
Returns the value of attribute front_matter.
8 9 10 |
# File 'lib/bookingit/config.rb', line 8 def front_matter @front_matter end |
#main_matter ⇒ Object (readonly)
Returns the value of attribute main_matter.
8 9 10 |
# File 'lib/bookingit/config.rb', line 8 def main_matter @main_matter end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/bookingit/config.rb', line 8 def end |
#rendering_config ⇒ Object (readonly)
Returns the value of attribute rendering_config.
8 9 10 |
# File 'lib/bookingit/config.rb', line 8 def rendering_config @rendering_config end |
#templates ⇒ Object (readonly)
Returns the value of attribute templates.
8 9 10 |
# File 'lib/bookingit/config.rb', line 8 def templates @templates end |