Class: SNMP::Integer
- Inherits:
-
Object
show all
- Includes:
- Comparable
- Defined in:
- lib/snmp/varbind.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(value) ⇒ Integer
Returns a new instance of Integer.
71
72
73
|
# File 'lib/snmp/varbind.rb', line 71
def initialize(value)
@value = value.to_i
end
|
Class Method Details
.decode(value_data) ⇒ Object
Instance Method Details
#<=>(other) ⇒ Object
75
76
77
|
# File 'lib/snmp/varbind.rb', line 75
def <=>(other)
@value <=> other.to_i
end
|
#asn1_type ⇒ Object
67
68
69
|
# File 'lib/snmp/varbind.rb', line 67
def asn1_type
"INTEGER"
end
|
#coerce(other) ⇒ Object
79
80
81
82
83
84
85
|
# File 'lib/snmp/varbind.rb', line 79
def coerce(other)
if other.kind_of? Fixnum
return [other, @value]
else
return [other.to_f, self.to_f]
end
end
|
#encode ⇒ Object
99
100
101
|
# File 'lib/snmp/varbind.rb', line 99
def encode
encode_integer(@value)
end
|
#to_f ⇒ Object
95
96
97
|
# File 'lib/snmp/varbind.rb', line 95
def to_f
@value.to_f
end
|
#to_i ⇒ Object
91
92
93
|
# File 'lib/snmp/varbind.rb', line 91
def to_i
@value
end
|
#to_oid ⇒ Object
103
104
105
106
|
# File 'lib/snmp/varbind.rb', line 103
def to_oid
raise RangeError, "@{value} cannot be an OID (must be >0)" if @value < 0
ObjectId.new([@value])
end
|
#to_s ⇒ Object
87
88
89
|
# File 'lib/snmp/varbind.rb', line 87
def to_s
@value.to_s
end
|