Class: Origami::Integer
- Inherits:
-
Bignum
- Object
- Bignum
- Origami::Integer
- Includes:
- Number
- Defined in:
- lib/origami/numeric.rb,
lib/origami/obfuscation.rb
Overview
Class representing an Integer Object.
Constant Summary collapse
- TOKENS =
:nodoc:
[ "(\\+|-)?[\\d]+[^.]?" ]
- REGEXP_TOKEN =
Regexp.new(TOKENS.first)
- @@regexp =
Regexp.new(WHITESPACES + "(?<int>(\\+|-)?[\\d]+)")
Instance Attribute Summary
Attributes included from Object
#file_offset, #generation, #no, #objstm_offset, #parent
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(i = 0) ⇒ Integer
constructor
Creates a new Integer from a Ruby Fixnum / Bignum.
Methods included from Number
#&, #*, #**, #+, #-, #-@, #/, #<<, #>>, #^, #abs, included, native_type, #to_s, #|, #~
Methods included from Object
#<=>, #cast_to, #copy, #document, #export, #indirect?, #indirect_parent, #logicalize, #logicalize!, native_type, #native_type, #post_build, #pre_build, #reference, #set_document, #set_indirect, skip_until_next_obj, #solve, #to_o, #to_s, #type, typeof, #version_required, #xrefs
Constructor Details
#initialize(i = 0) ⇒ Integer
Creates a new Integer from a Ruby Fixnum / Bignum.
- i
-
The Integer value.
116 117 118 119 120 121 122 |
# File 'lib/origami/numeric.rb', line 116 def initialize(i = 0) unless i.is_a?(::Integer) raise TypeError, "Expected type Fixnum or Bignum, received #{i.class}." end super(i) end |
Class Method Details
.parse(stream, parser = nil) ⇒ Object
:nodoc:
124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/origami/numeric.rb', line 124 def self.parse(stream, parser = nil) #:nodoc: offset = stream.pos if not stream.scan(@@regexp) raise InvalidIntegerObjectError, "Invalid integer format" end value = stream['int'].to_i int = Integer.new(value) int.file_offset = offset int end |