Class: KindleManager::BaseParser
- Inherits:
-
Object
- Object
- KindleManager::BaseParser
- Defined in:
- lib/kindle_manager/parsers/base_parser.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#fetched_at ⇒ Object
Returns the value of attribute fetched_at.
Instance Method Summary collapse
- #body ⇒ Object
- #doc ⇒ Object
-
#initialize(filepath, options = {}) ⇒ BaseParser
constructor
A new instance of BaseParser.
Constructor Details
#initialize(filepath, options = {}) ⇒ BaseParser
Returns a new instance of BaseParser.
5 6 7 8 9 10 11 12 13 |
# File 'lib/kindle_manager/parsers/base_parser.rb', line 5 def initialize(filepath, = {}) @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 |
Instance Attribute Details
#fetched_at ⇒ Object
Returns the value of attribute fetched_at.
3 4 5 |
# File 'lib/kindle_manager/parsers/base_parser.rb', line 3 def fetched_at @fetched_at end |
Instance Method Details
#body ⇒ Object
19 20 21 |
# File 'lib/kindle_manager/parsers/base_parser.rb', line 19 def body @body ||= File.read(@filepath) end |
#doc ⇒ Object
15 16 17 |
# File 'lib/kindle_manager/parsers/base_parser.rb', line 15 def doc @doc ||= Nokogiri::HTML(body) end |