Class: Sanford::Protocol::Response
- Inherits:
-
Struct
- Object
- Struct
- Sanford::Protocol::Response
- Defined in:
- lib/sanford-protocol/response.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#status ⇒ Object
Returns the value of attribute status.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #code ⇒ Object
- #code=(value) ⇒ Object
-
#initialize(status, data = nil) ⇒ Response
constructor
A new instance of Response.
- #inspect ⇒ Object
- #message ⇒ Object
- #message=(value) ⇒ Object
- #to_hash ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(status, data = nil) ⇒ Response
Returns a new instance of Response.
16 17 18 |
# File 'lib/sanford-protocol/response.rb', line 16 def initialize(status, data = nil) super(build_status(status), data) end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data
10 11 12 |
# File 'lib/sanford-protocol/response.rb', line 10 def data @data end |
#status ⇒ Object
Returns the value of attribute status
10 11 12 |
# File 'lib/sanford-protocol/response.rb', line 10 def status @status end |
Class Method Details
.parse(hash) ⇒ Object
12 13 14 |
# File 'lib/sanford-protocol/response.rb', line 12 def self.parse(hash) self.new(hash['status'], hash['data']) end |
Instance Method Details
#==(other) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/sanford-protocol/response.rb', line 37 def ==(other) if other.kind_of?(self.class) self.to_hash == other.to_hash else super end end |
#code ⇒ Object
20 |
# File 'lib/sanford-protocol/response.rb', line 20 def code; status.code; end |
#code=(value) ⇒ Object
21 |
# File 'lib/sanford-protocol/response.rb', line 21 def code=(value); status.code = value; end |
#inspect ⇒ Object
32 33 34 35 |
# File 'lib/sanford-protocol/response.rb', line 32 def inspect reference = '0x0%x' % (self.object_id << 1) "#<#{self.class}:#{reference} @status=#{status} @data=#{data.inspect}>" end |
#message ⇒ Object
22 |
# File 'lib/sanford-protocol/response.rb', line 22 def ; status.; end |
#message=(value) ⇒ Object
23 |
# File 'lib/sanford-protocol/response.rb', line 23 def (value); status. = value; end |
#to_hash ⇒ Object
26 27 28 29 30 |
# File 'lib/sanford-protocol/response.rb', line 26 def to_hash { 'status' => [status.code, status.], 'data' => data } end |
#to_s ⇒ Object
24 |
# File 'lib/sanford-protocol/response.rb', line 24 def to_s; status.to_s; end |