Class: User
- Inherits:
-
Object
- Object
- User
- Defined in:
- lib/User.rb
Instance Attribute Summary collapse
-
#login ⇒ Object
readonly
Returns the value of attribute login.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#travel_entries ⇒ Object
readonly
Returns the value of attribute travel_entries.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(login, pw, travel_entries) ⇒ User
constructor
A new instance of User.
- #new_travel_entry(country_name, region, date) ⇒ Object
- #to_json(*_args) ⇒ Object
Constructor Details
#initialize(login, pw, travel_entries) ⇒ User
9 10 11 12 13 |
# File 'lib/User.rb', line 9 def initialize(login, pw, travel_entries) @login = login @password = pw @travel_entries = travel_entries end |
Instance Attribute Details
#login ⇒ Object (readonly)
Returns the value of attribute login.
7 8 9 |
# File 'lib/User.rb', line 7 def login @login end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
7 8 9 |
# File 'lib/User.rb', line 7 def password @password end |
#travel_entries ⇒ Object (readonly)
Returns the value of attribute travel_entries.
7 8 9 |
# File 'lib/User.rb', line 7 def travel_entries @travel_entries end |
Class Method Details
.from_json(string) ⇒ Object
23 24 25 26 |
# File 'lib/User.rb', line 23 def self.from_json(string) data = JSON.load(File.read(string)) new(data['login'], data['password'], data['travel_entries']) end |
Instance Method Details
#new_travel_entry(country_name, region, date) ⇒ Object
15 16 17 |
# File 'lib/User.rb', line 15 def new_travel_entry(country_name, region, date) @travel_entries << { 'country' => country_name, 'region' => region, 'date' => date } end |
#to_json(*_args) ⇒ Object
19 20 21 |
# File 'lib/User.rb', line 19 def to_json(*_args) { 'login' => @login, 'password' => @password, 'travel_entries' => @travel_entries }.to_json end |