Class: Preferences
Instance Attribute Summary collapse
-
#credit_card ⇒ Object
Returns the value of attribute credit_card.
-
#email ⇒ Object
Returns the value of attribute email.
-
#name ⇒ Object
Returns the value of attribute name.
-
#note ⇒ Object
Returns the value of attribute note.
-
#phone_number ⇒ Object
Returns the value of attribute phone_number.
Instance Method Summary collapse
-
#initialize ⇒ Preferences
constructor
A new instance of Preferences.
Constructor Details
#initialize ⇒ Preferences
Returns a new instance of Preferences.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/preferences.rb', line 9 def initialize preferences_path = File.join(Dir.home, ".dominosjp.yml") return unless File.exist?(preferences_path) prefs = YAML.safe_load(File.read(preferences_path)).map { |k, v| [(k.to_sym rescue k), v] }.to_h self.email = prefs[:email] if prefs[:email] self.name = prefs[:name] if prefs[:name] self.phone_number = prefs[:phone_number] if prefs[:phone_number] self.credit_card = CreditCard.new(prefs[:credit_card]) if prefs[:credit_card] self.note = prefs[:note] if prefs[:note] end |
Instance Attribute Details
#credit_card ⇒ Object
Returns the value of attribute credit_card.
7 8 9 |
# File 'lib/preferences.rb', line 7 def credit_card @credit_card end |
#email ⇒ Object
Returns the value of attribute email.
7 8 9 |
# File 'lib/preferences.rb', line 7 def email @email end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/preferences.rb', line 7 def name @name end |
#note ⇒ Object
Returns the value of attribute note.
7 8 9 |
# File 'lib/preferences.rb', line 7 def note @note end |
#phone_number ⇒ Object
Returns the value of attribute phone_number.
7 8 9 |
# File 'lib/preferences.rb', line 7 def phone_number @phone_number end |