Class: MassInvite::Customer
- Inherits:
-
Object
- Object
- MassInvite::Customer
- Defined in:
- lib/mass_invite/customer.rb
Overview
Customer class
Instance Attribute Summary collapse
-
#location ⇒ Object
Returns the value of attribute location.
-
#name ⇒ Object
Returns the value of attribute name.
-
#user_id ⇒ Object
Returns the value of attribute user_id.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(user_id, name, location) ⇒ Customer
constructor
A new instance of Customer.
Constructor Details
#initialize(user_id, name, location) ⇒ Customer
Returns a new instance of Customer.
26 27 28 29 30 |
# File 'lib/mass_invite/customer.rb', line 26 def initialize(user_id, name, location) self.user_id = user_id self.name = name self.location = location end |
Instance Attribute Details
#location ⇒ Object
Returns the value of attribute location.
24 25 26 |
# File 'lib/mass_invite/customer.rb', line 24 def location @location end |
#name ⇒ Object
Returns the value of attribute name.
23 24 25 |
# File 'lib/mass_invite/customer.rb', line 23 def name @name end |
#user_id ⇒ Object
Returns the value of attribute user_id.
23 24 25 |
# File 'lib/mass_invite/customer.rb', line 23 def user_id @user_id end |
Class Method Details
.create_from_file(path = nil) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/mass_invite/customer.rb', line 50 def self.create_from_file(path = nil) default_path = File.('../../../data/customers', __FILE__) customers_file = if path File.open(path) else File.open(default_path) end customers_file.each_line.map do |line| create_from_json_string(line) end end |
.create_from_json_string(line) ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/mass_invite/customer.rb', line 64 def self.create_from_json_string(line) parsed_line = JSON.parse(line, symbolize_names: true) loc = Location.new(parsed_line[:latitude], parsed_line[:longitude]) Customer.new(parsed_line[:user_id], parsed_line[:name], loc) end |