Class: SeparatedValues::Row
- Inherits:
-
Object
- Object
- SeparatedValues::Row
- Defined in:
- lib/separated_values/row.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #[](index) ⇒ Object
-
#initialize(values, options = DEFAULT_OPTIONS) ⇒ Row
constructor
A new instance of Row.
- #to_h(schema = options[:schema]) ⇒ Object
Constructor Details
#initialize(values, options = DEFAULT_OPTIONS) ⇒ Row
Returns a new instance of Row.
5 6 7 8 |
# File 'lib/separated_values/row.rb', line 5 def initialize(values, = DEFAULT_OPTIONS) @values = values @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/separated_values/row.rb', line 3 def @options end |
Instance Method Details
#[](index) ⇒ Object
10 11 12 |
# File 'lib/separated_values/row.rb', line 10 def [](index) @values[index] end |
#to_h(schema = options[:schema]) ⇒ Object
14 15 16 17 18 |
# File 'lib/separated_values/row.rb', line 14 def to_h(schema = [:schema]) schema.each_with_object({}).with_index do |(key, hash), i| hash[key] = @values[i] end end |