Method: OpenC3::CSV#float

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

#float(item, index = 0) ⇒ Float

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

Parameters:

  • item (String)

    Key to access the value

  • index (Integer) (defaults to: 0)

    Which value to return

Returns:

  • (Float)

    Single value converted to a float



111
112
113
114
115
116
117
118
119
# File 'lib/openc3/utilities/csv.rb', line 111

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

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