Skip to content

Instantly share code, notes, and snippets.

View jyothu's full-sized avatar

Jyothish Kumar K R jyothu

View GitHub Profile
@jyothu
jyothu / vehicle.rb
Created March 25, 2019 12:41
Implement count method - Usage of class variable & instance variable
class Vehicle
end
class Car < Vehicle
end
class Bus < Vehicle
end
class Jeep < Vehicle
# Given an amount like 57 cents
# return how many of each denomination needed to make that total
# these are the denominations:
# 1 cent, 5 cent, 10 cent, 25 cent
# Refactor this!
def import(file, partner)
raise if filepath[-3..-1] != 'csv'
CSV.foreach(filepath, headers: true, header_converters: CSV::HeaderConverters[:symbol]) do |row|
order = Order.find_or_initialize_by(partner_order_number: row["order_number"])
location = Location.find_by(location_number: row["location_number"])
customer = Customer.find_by(email: customer_profile.customer_id)