Class: Bookery::Factories::ChapterFactory::Chapter
- Inherits:
-
Object
- Object
- Bookery::Factories::ChapterFactory::Chapter
- Defined in:
- lib/bookery/factories/chapter_factory.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #combine_chapter_files(dir) ⇒ Object
-
#initialize(chapter_dir) ⇒ Chapter
constructor
A new instance of Chapter.
Constructor Details
#initialize(chapter_dir) ⇒ Chapter
Returns a new instance of Chapter.
22 23 24 25 |
# File 'lib/bookery/factories/chapter_factory.rb', line 22 def initialize(chapter_dir) @name = File.basename(chapter_dir) @content = combine_chapter_files(chapter_dir) end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
20 21 22 |
# File 'lib/bookery/factories/chapter_factory.rb', line 20 def content @content end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
20 21 22 |
# File 'lib/bookery/factories/chapter_factory.rb', line 20 def name @name end |
Instance Method Details
#combine_chapter_files(dir) ⇒ Object
27 28 29 30 31 |
# File 'lib/bookery/factories/chapter_factory.rb', line 27 def combine_chapter_files(dir) Dir.glob(File.join(dir, '*.md')).sort.inject('') do |content, file| content << File.read(file) << "\n" end end |