Class: Mackerel::Channel
- Inherits:
-
Object
- Object
- Mackerel::Channel
- Defined in:
- lib/mackerel/channel.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ Channel
constructor
A new instance of Channel.
- #to_h ⇒ Object
- #to_json(options = nil) ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Channel
Returns a new instance of Channel.
4 5 6 7 8 |
# File 'lib/mackerel/channel.rb', line 4 def initialize(args = {}) @id = args["id"] @name = args["name"] @type = args["type"] end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/mackerel/channel.rb', line 3 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/mackerel/channel.rb', line 3 def name @name end |
#type ⇒ Object
Returns the value of attribute type.
3 4 5 |
# File 'lib/mackerel/channel.rb', line 3 def type @type end |
Instance Method Details
#to_h ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/mackerel/channel.rb', line 10 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
18 19 20 |
# File 'lib/mackerel/channel.rb', line 18 def to_json( = nil) return to_h.to_json() end |