Class: MakeBook::Chapter

Inherits:
Object
  • Object
show all
Defined in:
lib/makebook/chapter.rb

Overview

A book chapter

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file = nil, book: nil, name: nil) ⇒ Chapter

Returns a new instance of Chapter.



5
6
7
8
# File 'lib/makebook/chapter.rb', line 5

def initialize(file = nil, book: nil, name: nil)
  file ||= book.root + "#{name}.md"
  @source = Pathname.new(file)
end

Instance Attribute Details

#sourceObject (readonly)

Returns the value of attribute source.



3
4
5
# File 'lib/makebook/chapter.rb', line 3

def source
  @source
end

Instance Method Details

#rootObject



10
11
12
# File 'lib/makebook/chapter.rb', line 10

def root
  source.dirname
end