Class: HasherizeCsv::Csv
- Inherits:
-
Object
- Object
- HasherizeCsv::Csv
- Includes:
- Enumerable
- Defined in:
- lib/hasherize_csv.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
Returns the value of attribute file.
-
#keys ⇒ Object
Returns the value of attribute keys.
-
#separator ⇒ Object
Returns the value of attribute separator.
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(file, opts = {}) ⇒ Csv
constructor
A new instance of Csv.
Constructor Details
#initialize(file, opts = {}) ⇒ Csv
Returns a new instance of Csv.
12 13 14 15 16 17 18 |
# File 'lib/hasherize_csv.rb', line 12 def initialize file, opts = {} @file = file @separator = opts[:separator] || DefaultOpts::DEFAULT[:separator] @value_pattern = opts[:value_pattern] || DefaultOpts::DEFAULT[:value_pattern] @keys = [] @keys = values_from_line next_line end |
Instance Attribute Details
#file ⇒ Object
Returns the value of attribute file.
11 12 13 |
# File 'lib/hasherize_csv.rb', line 11 def file @file end |
#keys ⇒ Object
Returns the value of attribute keys.
11 12 13 |
# File 'lib/hasherize_csv.rb', line 11 def keys @keys end |
#separator ⇒ Object
Returns the value of attribute separator.
11 12 13 |
# File 'lib/hasherize_csv.rb', line 11 def separator @separator end |
Instance Method Details
#each ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/hasherize_csv.rb', line 20 def each return self.to_enum if !block_given? until (hash = next_item).nil? yield hash end end |