class Bookshelf::Stats
Attributes
root_dir[R]
Public Class Methods
new(root_dir)
click to toggle source
# File lib/bookshelf/stats.rb, line 5 def initialize(root_dir) @root_dir = root_dir end
Public Instance Methods
chapters()
click to toggle source
# File lib/bookshelf/stats.rb, line 21 def chapters @chapters ||= html.css(".chapter").size end
content()
click to toggle source
# File lib/bookshelf/stats.rb, line 33 def content @content ||= Parser::HTML.new(root_dir).content end
html()
click to toggle source
# File lib/bookshelf/stats.rb, line 13 def html @html ||= Nokogiri::HTML(content) end
images()
click to toggle source
# File lib/bookshelf/stats.rb, line 25 def images @images ||= html.css("img").size end
links()
click to toggle source
# File lib/bookshelf/stats.rb, line 29 def links @links ||= html.css("[href^='http']").size end
text()
click to toggle source
# File lib/bookshelf/stats.rb, line 9 def text @text ||= html.text end
words()
click to toggle source
# File lib/bookshelf/stats.rb, line 17 def words @words ||= text.split(" ").size end