Class: RASN1::Types::Integer
- Defined in:
- lib/rasn1/types/integer.rb
Overview
ASN.1 Integer
Direct Known Subclasses
Constant Summary collapse
- ID =
Integer id value
2
Constants inherited from Primitive
Constants inherited from Base
Base::CLASSES, Base::CLASS_MASK, Base::INDEFINITE_LENGTH, Base::MULTI_OCTETS_ID
Instance Attribute Summary collapse
- #enum ⇒ Hash? readonly
Attributes inherited from Base
#asn1_class, #default, #name, #options
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Integer
constructor
A new instance of Integer.
-
#to_i ⇒ Integer
Integer value.
- #value=(val) ⇒ void
- #void_value ⇒ Integer
Methods inherited from Base
#==, #can_build?, constrained?, #constructed?, #do_parse_explicit_with_tracing, #do_parse_with_tracing, encoded_type, #explicit?, #id, #implicit?, #initialize_copy, #inspect, #optional?, parse, #parse!, #primitive?, #specific_initializer, start_tracing, stop_tracing, #tagged?, #to_der, #trace, type, #type, #value, #value?, #value_size
Constructor Details
#initialize(options = {}) ⇒ Integer
Returns a new instance of Integer.
18 19 20 21 |
# File 'lib/rasn1/types/integer.rb', line 18 def initialize(={}) super initialize_enum(@options[:enum]) end |
Instance Attribute Details
#enum ⇒ Hash? (readonly)
9 10 11 |
# File 'lib/rasn1/types/integer.rb', line 9 def enum @enum end |
Instance Method Details
#to_i ⇒ Integer
Integer value
47 48 49 50 51 52 53 54 55 |
# File 'lib/rasn1/types/integer.rb', line 47 def to_i val = value? ? @value : @default case val when String, Symbol @enum[val] else val || 0 end end |
#value=(val) ⇒ void
This method returns an undefined value.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rasn1/types/integer.rb', line 25 def value=(val) @no_value = false case val when String, Symbol value_from_string_or_symbol(val) when ::Integer value_from_integer(val) when nil @no_value = true @value = void_value else raise EnumeratedError, "#{@name}: not in enumeration" end end |