Class: Devinci::Base
- Inherits:
-
Object
- Object
- Devinci::Base
- Defined in:
- lib/devinci/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #downloaded_on ⇒ Object
-
#initialize(filename, options = {}) ⇒ Base
constructor
A new instance of Base.
- #io ⇒ Object
- #parse ⇒ Object
Constructor Details
#initialize(filename, options = {}) ⇒ Base
Returns a new instance of Base.
7 8 9 10 |
# File 'lib/devinci/base.rb', line 7 def initialize(filename, = {}) @filename = filename @options = end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
5 6 7 |
# File 'lib/devinci/base.rb', line 5 def filename @filename end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/devinci/base.rb', line 5 def @options end |
Instance Method Details
#downloaded_on ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/devinci/base.rb', line 21 def downloaded_on match = filename.match(/(\d{4})-(\d{2})-(\d{2})..(\d{2}):(\d{2}):(\d{2})/) if match numbers = (1..6).map { |n| match[n].to_i } Time.utc(*numbers) end end |
#io ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/devinci/base.rb', line 12 def io @io ||= case @options[:compression] when :gzip Zlib::GzipReader.open(@filename) else File.open(@filename) end end |
#parse ⇒ Object
29 30 31 |
# File 'lib/devinci/base.rb', line 29 def parse raise NotImplementedError, "Each parser must define their own parse method" end |