Class: Snmpjr::Response
- Inherits:
-
Object
- Object
- Snmpjr::Response
- Defined in:
- lib/snmpjr/response.rb
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#oid ⇒ Object
readonly
Returns the value of attribute oid.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #error? ⇒ Boolean
-
#initialize(response = {}) ⇒ Response
constructor
A new instance of Response.
- #to_h ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(response = {}) ⇒ Response
Returns a new instance of Response.
5 6 7 8 9 10 |
# File 'lib/snmpjr/response.rb', line 5 def initialize response = {} @error = response[:error] || '' @value = response[:value] || '' @oid = response[:oid] || '' @type = response[:type] || '' end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
3 4 5 |
# File 'lib/snmpjr/response.rb', line 3 def error @error end |
#oid ⇒ Object (readonly)
Returns the value of attribute oid.
3 4 5 |
# File 'lib/snmpjr/response.rb', line 3 def oid @oid end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
3 4 5 |
# File 'lib/snmpjr/response.rb', line 3 def type @type end |
Instance Method Details
#==(other) ⇒ Object
28 29 30 31 |
# File 'lib/snmpjr/response.rb', line 28 def ==(other) return false unless other.instance_of?(self.class) @error == other.error && to_h == other.to_h end |
#error? ⇒ Boolean
12 13 14 15 16 17 18 |
# File 'lib/snmpjr/response.rb', line 12 def error? if @error.empty? false else true end end |
#to_h ⇒ Object
20 21 22 |
# File 'lib/snmpjr/response.rb', line 20 def to_h { oid: @oid, value: @value, type: @type } end |
#to_s ⇒ Object
24 25 26 |
# File 'lib/snmpjr/response.rb', line 24 def to_s @value end |