class Motors::Motor
Attributes
data[R]
Public Class Methods
new(filename)
click to toggle source
# File lib/frc-motors.rb, line 8 def initialize(filename) @data = CSV.read(get_path(filename), { headers: true, converters: :float , header_converters: :symbol }) end
Public Instance Methods
find(colname, value)
click to toggle source
# File lib/frc-motors.rb, line 12 def find(colname, value) best_row = @data[0] @data.each do |row| if (row[colname].to_f - value).abs < (best_row[colname].to_f - value).abs best_row = row end end best_row end
get_path(filename)
click to toggle source
# File lib/frc-motors.rb, line 24 def get_path(filename) File.dirname(File.expand_path(__FILE__))+"/../data/#{filename}.csv" end