class CSVConverter
Public Class Methods
new(convert)
click to toggle source
# File lib/csv_converter.rb, line 2 def initialize(convert) @key = convert.keys.first @conversion = convert[@key] end
Public Instance Methods
convert(hash)
click to toggle source
# File lib/csv_converter.rb, line 7 def convert(hash) case @conversion when :integer hash[@key] = hash[@key].to_i when :float hash[@key] = hash[@key].to_f when :string # nop, default else raise ArgumentError.new("Unknown converter: `#{@conversion}`") end hash end