Class: Mackerel::User
- Inherits:
-
Object
- Object
- Mackerel::User
- Defined in:
- lib/mackerel/user.rb
Instance Attribute Summary collapse
-
#email ⇒ Object
Returns the value of attribute email.
-
#id ⇒ Object
Returns the value of attribute id.
-
#screenName ⇒ Object
Returns the value of attribute screenName.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ User
constructor
A new instance of User.
- #to_h ⇒ Object
- #to_json(options = nil) ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ User
Returns a new instance of User.
5 6 7 8 9 |
# File 'lib/mackerel/user.rb', line 5 def initialize(args = {}) @id = args["id"] @screenName = args["screenName"] @email = args["email"] end |
Instance Attribute Details
#email ⇒ Object
Returns the value of attribute email.
4 5 6 |
# File 'lib/mackerel/user.rb', line 4 def email @email end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/mackerel/user.rb', line 4 def id @id end |
#screenName ⇒ Object
Returns the value of attribute screenName.
4 5 6 |
# File 'lib/mackerel/user.rb', line 4 def screenName @screenName end |
Instance Method Details
#to_h ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/mackerel/user.rb', line 11 def to_h instance_variables.flat_map do |name| respond_to?(name[1..-1]) ? [name[1..-1]] : [] end.each_with_object({}) do |name, hash| hash[name] = public_send(name) end.delete_if { |key, val| val == nil } end |
#to_json(options = nil) ⇒ Object
19 20 21 |
# File 'lib/mackerel/user.rb', line 19 def to_json( = nil) return to_h.to_json() end |