Sha256: e4cb087ffae7d220433b413542c82c5f13470ad8a13c370d2c61397f2752b52f

Contents?: true

Size: 589 Bytes

Versions: 1

Compression:

Stored size: 589 Bytes

Contents

module Bookshelf
  class Stats
    attr_reader :root_dir

    def initialize(root_dir)
      @root_dir = root_dir
    end

    def text
      @text ||= html.text
    end

    def html
      @html ||= Nokogiri::HTML(content)
    end

    def words
      @words ||= text.split(" ").size
    end

    def chapters
      @chapters ||= html.css(".chapter").size
    end

    def images
      @images ||= html.css("img").size
    end

    def links
      @links ||= html.css("[href^='http']").size
    end

    def content
      @content ||= Parser::HTML.new(root_dir).content
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bookshelf-1.2.4 lib/bookshelf/stats.rb