Method: OpenC3::CSV#string

Defined in:
lib/openc3/utilities/csv.rb

#string(item, index = 0) ⇒ String Also known as: str

Convenience method to access a value by key and convert it to a string

Parameters:

  • item (String)

    Key to access the value

  • index (Integer) (defaults to: 0)

    Which value to return

Returns:

  • (String)

    Single value converted to a string



126
127
128
129
130
131
132
133
134
# File 'lib/openc3/utilities/csv.rb', line 126

def string(item, index = 0)
  raise "#{item} not found" unless keys.include?(item)

  if Range === index
    @hash[item][index].map { |x| x.to_s }
  else
    @hash[item][index].to_s
  end
end