Class: BooksParser

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll-books/books_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#booksObject (readonly)

Returns the value of attribute books.



4
5
6
# File 'lib/jekyll-books/books_parser.rb', line 4

def books
  @books
end

#pagesObject (readonly)

Returns the value of attribute pages.



4
5
6
# File 'lib/jekyll-books/books_parser.rb', line 4

def pages
  @pages
end

#rootObject (readonly)

Returns the value of attribute root.



4
5
6
# File 'lib/jekyll-books/books_parser.rb', line 4

def root
  @root
end

#siteObject (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_pathObject



13
14
15
# File 'lib/jekyll-books/books_parser.rb', line 13

def root_path
  File.join(site.source, root)
end