Class: SNMP::Integer

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/snmp/varbind.rb

Direct Known Subclasses

Counter64, Integer32, UnsignedInteger

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Integer

Returns a new instance of Integer.



65
66
67
# File 'lib/snmp/varbind.rb', line 65

def initialize(value)
    @value = value.to_i
end

Class Method Details

.decode(value_data) ⇒ Object



57
58
59
# File 'lib/snmp/varbind.rb', line 57

def self.decode(value_data)
    Integer.new(decode_integer_value(value_data))
end

Instance Method Details

#<=>(other) ⇒ Object



69
70
71
# File 'lib/snmp/varbind.rb', line 69

def <=>(other)
    @value <=> other.to_i
end

#asn1_typeObject



61
62
63
# File 'lib/snmp/varbind.rb', line 61

def asn1_type
    "INTEGER"
end

#coerce(other) ⇒ Object



73
74
75
76
77
78
79
# File 'lib/snmp/varbind.rb', line 73

def coerce(other)
    if other.kind_of? Fixnum
        return [other, @value]
    else
        return [other.to_f, self.to_f]
    end
end

#encodeObject



93
94
95
# File 'lib/snmp/varbind.rb', line 93

def encode
    encode_integer(@value)
end

#to_fObject



89
90
91
# File 'lib/snmp/varbind.rb', line 89

def to_f
    @value.to_f
end

#to_iObject



85
86
87
# File 'lib/snmp/varbind.rb', line 85

def to_i
    @value
end

#to_sObject



81
82
83
# File 'lib/snmp/varbind.rb', line 81

def to_s
    @value.to_s
end