Class: BooksParser
- Inherits:
-
Object
- Object
- BooksParser
- Defined in:
- lib/jekyll-books/books_parser.rb
Instance Attribute Summary collapse
-
#books ⇒ Object
readonly
Returns the value of attribute books.
-
#pages ⇒ Object
readonly
Returns the value of attribute pages.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#site ⇒ Object
readonly
Returns the value of attribute site.
Instance Method Summary collapse
-
#initialize(root, site) ⇒ BooksParser
constructor
A new instance of BooksParser.
- #parse(params) ⇒ Object
- #root_path ⇒ Object
Constructor Details
#initialize(root, site) ⇒ BooksParser
Returns a new instance of BooksParser.
6 7 8 9 10 11 |
# File 'lib/jekyll-books/books_parser.rb', line 6 def initialize(root, site) @root = root @site = site @books = [] @pages = [] end |
Instance Attribute Details
#books ⇒ Object (readonly)
Returns the value of attribute books.
4 5 6 |
# File 'lib/jekyll-books/books_parser.rb', line 4 def books @books end |
#pages ⇒ Object (readonly)
Returns the value of attribute pages.
4 5 6 |
# File 'lib/jekyll-books/books_parser.rb', line 4 def pages @pages end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
4 5 6 |
# File 'lib/jekyll-books/books_parser.rb', line 4 def root @root end |
#site ⇒ Object (readonly)
Returns the value of attribute site.
4 5 6 |
# File 'lib/jekyll-books/books_parser.rb', line 4 def site @site end |
Instance Method Details
#parse(params) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/jekyll-books/books_parser.rb', line 17 def parse(params) Dir.foreach(root_path) do |book_dir| book_path = File.join(root_path, book_dir) if File.directory?(book_path) and book_dir.chars.first != "." pages = BookReader.new(params, site, book_dir).read books << pages[0] @pages += pages end end end |
#root_path ⇒ Object
13 14 15 |
# File 'lib/jekyll-books/books_parser.rb', line 13 def root_path File.join(site.source, root) end |