Class: DogWatch::Model::Response
- Inherits:
-
Object
- Object
- DogWatch::Model::Response
- Extended by:
- Mixin::Colorize
- Defined in:
- lib/dogwatch/model/response.rb
Overview
Takes DataDog client responses and formats them nicely
Constant Summary collapse
- ERROR =
'400'.freeze
- CREATED =
'200'.freeze
- ACCEPTED =
'202'.freeze
Instance Attribute Summary collapse
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
- #initialize(response, name, updated = false) ⇒ DogWatch::Model::Response constructor
- #message ⇒ String
- #status ⇒ Symbol
- #to_thor ⇒ Array
Methods included from Mixin::Colorize
Constructor Details
#initialize(response, name, updated = false) ⇒ DogWatch::Model::Response
26 27 28 29 30 31 32 33 34 |
# File 'lib/dogwatch/model/response.rb', line 26 def initialize(response, name, updated = false) @response = response @updated = updated @name = if response[1]['name'].nil? name else response[1]['name'] end end |
Instance Attribute Details
#response ⇒ Object
Returns the value of attribute response.
20 21 22 |
# File 'lib/dogwatch/model/response.rb', line 20 def response @response end |
Instance Method Details
#message ⇒ String
45 46 47 |
# File 'lib/dogwatch/model/response.rb', line 45 def send(status, @response[1]) end |
#status ⇒ Symbol
37 38 39 40 41 42 |
# File 'lib/dogwatch/model/response.rb', line 37 def status return :updated if @updated == true return :created if created? return :error if failed? return :accepted if accepted? end |
#to_thor ⇒ Array
50 51 52 53 54 |
# File 'lib/dogwatch/model/response.rb', line 50 def to_thor action = status text = [action, text, color] end |