Class: Bookingit::Config::Chapter

Inherits:
Object
  • Object
show all
Defined in:
lib/bookingit/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(markdown_path: nil, relative_url: nil) ⇒ Chapter

Returns a new instance of Chapter.



77
78
79
80
81
# File 'lib/bookingit/config.rb', line 77

def initialize(markdown_path: nil, relative_url: nil)
  @markdown_path = markdown_path
  @relative_url = relative_url || (File.basename(markdown_path, File.extname(markdown_path)) + ".html")
  @sections = []
end

Instance Attribute Details

#markdown_pathObject (readonly)

Returns the value of attribute markdown_path.



74
75
76
# File 'lib/bookingit/config.rb', line 74

def markdown_path
  @markdown_path
end

#next_chapterObject

Returns the value of attribute next_chapter.



75
76
77
# File 'lib/bookingit/config.rb', line 75

def next_chapter
  @next_chapter
end

#previous_chapterObject

Returns the value of attribute previous_chapter.



75
76
77
# File 'lib/bookingit/config.rb', line 75

def previous_chapter
  @previous_chapter
end

#relative_urlObject (readonly)

Returns the value of attribute relative_url.



74
75
76
# File 'lib/bookingit/config.rb', line 74

def relative_url
  @relative_url
end

#sectionsObject (readonly)

Returns the value of attribute sections.



74
75
76
# File 'lib/bookingit/config.rb', line 74

def sections
  @sections
end

#titleObject

Returns the value of attribute title.



75
76
77
# File 'lib/bookingit/config.rb', line 75

def title
  @title
end

Instance Method Details

#add_section(title, anchor) ⇒ Object



83
84
85
86
87
# File 'lib/bookingit/config.rb', line 83

def add_section(title,anchor)
  section = Chapter.new(relative_url: self.relative_url + "##{anchor}")
  section.title = title
  @sections << section
end