Sha256: cb5f63eadd37d2c8bb08906e1dc0025fec2d861b80af406bfb5ab56748394548

Contents?: true

Size: 496 Bytes

Versions: 10

Compression:

Stored size: 496 Bytes

Contents

module KindleManager
  class BaseParser
    attr_accessor :fetched_at

    def initialize(filepath, options = {})
      @filepath = filepath

      @fetched_at = if File.basename(@filepath) =~ /\A\d{14}/
        Time.strptime(File.basename(@filepath)[0..14], KindleManager::FileStore::TIME_FORMAT_FOR_FILENAME)
      else
        File.ctime(@filepath)
      end
    end

    def doc
      @doc ||= Nokogiri::HTML(body)
    end

    def body
      @body ||= File.read(@filepath)
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
kindle_manager-0.9.1 lib/kindle_manager/parsers/base_parser.rb
kindle_manager-0.9.0 lib/kindle_manager/parsers/base_parser.rb
kindle_manager-0.8.0 lib/kindle_manager/parsers/base_parser.rb
kindle_manager-0.7.0 lib/kindle_manager/parsers/base_parser.rb
kindle_manager-0.6.4 lib/kindle_manager/parsers/base_parser.rb
kindle_manager-0.6.3 lib/kindle_manager/parsers/base_parser.rb
kindle_manager-0.6.2 lib/kindle_manager/parsers/base_parser.rb
kindle_manager-0.6.1 lib/kindle_manager/parsers/base_parser.rb
kindle_manager-0.6.0 lib/kindle_manager/parsers/base_parser.rb
kindle_manager-0.5.0 lib/kindle_manager/parsers/base_parser.rb