Class: Origami::Integer
- Inherits:
-
Integer
- Object
- Integer
- 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.
-
#to_s(eol: $/) ⇒ Object
(also: #to_obfuscated_str)
:nodoc:.
Methods included from Number
#&, #*, #**, #+, #-, #-@, #/, #<<, #>>, #^, #abs, #|, #~
Methods included from Object
#cast_to, #copy, #document, #export, included, #indirect?, #indirect_parent, #logicalize, #logicalize!, #native_type, #numbered?, #post_build, #pre_build, #reference, #set_document, #set_indirect, skip_until_next_obj, #solve, #to_o, #type, typeof, #version_required, #xrefs
Constructor Details
#initialize(i = 0) ⇒ Integer
Creates a new Integer from a Ruby Fixnum / Bignum.
- i
-
The Integer value.
102 103 104 105 106 107 108 |
# File 'lib/origami/numeric.rb', line 102 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:
110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/origami/numeric.rb', line 110 def self.parse(stream, _parser = nil) #:nodoc: scanner = Parser.init_scanner(stream) offset = scanner.pos if not scanner.scan(@@regexp) raise InvalidIntegerObjectError, "Invalid integer format" end value = scanner['int'].to_i int = Integer.new(value) int.file_offset = offset int end |
Instance Method Details
#to_s(eol: $/) ⇒ Object Also known as: to_obfuscated_str
:nodoc:
125 126 127 |
# File 'lib/origami/numeric.rb', line 125 def to_s(eol: $/) #:nodoc: super(self.value.to_s, eol: eol) end |