class SeparatedValues::Row
Attributes
options[R]
Public Class Methods
new(values, options = DEFAULT_OPTIONS)
click to toggle source
# File lib/separated_values/row.rb, line 5 def initialize(values, options = DEFAULT_OPTIONS) @values = values @options = options end
Public Instance Methods
[](index)
click to toggle source
# File lib/separated_values/row.rb, line 10 def [](index) @values[index] end
method_missing(name, *args, &block)
click to toggle source
Calls superclass method
# File lib/separated_values/row.rb, line 20 def method_missing(name, *args, &block) return to_h[name] if respond_to_missing?(name, *args) super end
respond_to_missing?(name, *args)
click to toggle source
# File lib/separated_values/row.rb, line 25 def respond_to_missing?(name, *args) !!options[:schema] && options[:schema].include?(name) end
to_h(schema = options[:schema])
click to toggle source
# File lib/separated_values/row.rb, line 14 def to_h(schema = options[:schema]) schema.each_with_object({}).with_index do |(key, hash), i| hash[key] = @values[i] end end