Class: FirebaseStats::Reader
- Inherits:
-
Object
- Object
- FirebaseStats::Reader
- Defined in:
- lib/reader.rb
Overview
Parses the Firebase CSV file into sections
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
-
#initialize ⇒ Reader
constructor
A new instance of Reader.
- #parse(input) ⇒ Object
- #parse_file(filename) ⇒ Object
Constructor Details
#initialize ⇒ Reader
Returns a new instance of Reader.
10 11 12 13 |
# File 'lib/reader.rb', line 10 def initialize super @data = {} end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
8 9 10 |
# File 'lib/reader.rb', line 8 def data @data end |
Instance Method Details
#parse(input) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/reader.rb', line 22 def parse(input) curr_lines = [] input.each_with_index do |line, idx| curr_lines.push(line) unless comment?(line) || line.strip.empty? if (idx == input.length - 1) || line.strip.empty? process_lines curr_lines unless curr_lines.empty? curr_lines = [] end end end |
#parse_file(filename) ⇒ Object
16 17 18 19 |
# File 'lib/reader.rb', line 16 def parse_file(filename) lines = File.readlines(filename) parse(lines) end |