Class: NPR::API::Message

Inherits:
Object
  • Object
show all
Includes:
Concern::ShallowAttributes
Defined in:
lib/npr/api/message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Concern::ShallowAttributes

included

Constructor Details

#initialize(json) ⇒ Message




17
18
19
20
21
22
23
# File 'lib/npr/api/message.rb', line 17

def initialize(json)
  @_json = json
  @id    = @_json["id"]
  @level = @_json["level"]

  extract_shallow_attributes(@_json)
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



12
13
14
# File 'lib/npr/api/message.rb', line 12

def id
  @id
end

#levelObject

Returns the value of attribute level.



12
13
14
# File 'lib/npr/api/message.rb', line 12

def level
  @level
end

Instance Method Details

#error?Boolean


Returns:

  • (Boolean)


27
28
29
# File 'lib/npr/api/message.rb', line 27

def error?
  self.level == "error"
end

#warning?Boolean


Returns:

  • (Boolean)


33
34
35
# File 'lib/npr/api/message.rb', line 33

def warning?
  self.level == "warning"
end