Class: GoApiClient::User
- Inherits:
-
Object
- Object
- GoApiClient::User
- Defined in:
- lib/go_api_client/user.rb
Instance Attribute Summary collapse
-
#email ⇒ Object
Returns the value of attribute email.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #hash ⇒ Object
-
#initialize(name, email) ⇒ User
constructor
A new instance of User.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name, email) ⇒ User
Returns a new instance of User.
6 7 8 9 |
# File 'lib/go_api_client/user.rb', line 6 def initialize(name, email) @name = name @email = email end |
Instance Attribute Details
#email ⇒ Object
Returns the value of attribute email.
4 5 6 |
# File 'lib/go_api_client/user.rb', line 4 def email @email end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/go_api_client/user.rb', line 4 def name @name end |
Class Method Details
.parse(str) ⇒ Object
30 31 32 33 |
# File 'lib/go_api_client/user.rb', line 30 def parse(str) _, name, email = *str.match(/(.*) <(.+?)>/) self.new(name.strip, email.strip) end |
Instance Method Details
#==(other) ⇒ Object
11 12 13 14 15 |
# File 'lib/go_api_client/user.rb', line 11 def ==(other) other && self.class.equal?(other.class) && name == other.name && email == other.email end |
#hash ⇒ Object
17 18 19 |
# File 'lib/go_api_client/user.rb', line 17 def hash self.class.hash ^ name.hash ^ email.hash end |
#inspect ⇒ Object
25 26 27 |
# File 'lib/go_api_client/user.rb', line 25 def inspect "User(#{to_s})" end |
#to_s ⇒ Object
21 22 23 |
# File 'lib/go_api_client/user.rb', line 21 def to_s "#{name} <#{email}>" end |