Class: Snmpjr::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/snmpjr/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#errorObject (readonly)

Returns the value of attribute error.



3
4
5
# File 'lib/snmpjr/response.rb', line 3

def error
  @error
end

#oidObject (readonly)

Returns the value of attribute oid.



3
4
5
# File 'lib/snmpjr/response.rb', line 3

def oid
  @oid
end

#typeObject (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

Returns:

  • (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_hObject



20
21
22
# File 'lib/snmpjr/response.rb', line 20

def to_h
  { oid: @oid, value: @value, type: @type }
end

#to_sObject



24
25
26
# File 'lib/snmpjr/response.rb', line 24

def to_s
  @value
end