Class: Origami::Real
- Includes:
- Number
- Defined in:
- lib/origami/numeric.rb,
lib/origami/obfuscation.rb
Overview
Class representing a Real number Object. PDF real numbers are arbitrary precision numbers, depending on architectures.
Constant Summary collapse
- TOKENS =
:nodoc:
[ "(\\+|-)?([\\d]*\\.[\\d]+|[\\d]+\\.[\\d]*)([eE](\\+|-)?[\\d]+)?" ]
- REGEXP_TOKEN =
Regexp.new(TOKENS.first)
- @@regexp =
Regexp.new(WHITESPACES + "(" + TOKENS.first + ")")
Instance Attribute Summary
Attributes included from Object
#file_offset, #generation, #no, #objstm_offset, #parent
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(f = 0) ⇒ Real
constructor
Creates a new Real from a Ruby Float.
- #to_s ⇒ Object (also: #to_obfuscated_str)
Methods included from Number
#&, #*, #**, #+, #-, #-@, #/, #<<, #>>, #^, #abs, included, native_type, #|, #~
Methods included from Object
#<=>, #cast_to, #copy, #export, #indirect_parent, #is_indirect?, #logicalize, #logicalize!, native_type, #native_type, #pdf, #pdf_version_required, #post_build, #pre_build, #reference, #resolve_all_references, #set_indirect, #set_pdf, #size, skip_until_next_obj, #solve, #to_o, #type, typeof, #xrefs
Methods inherited from Float
Constructor Details
Class Method Details
.parse(stream, parser = nil) ⇒ Object
:nodoc:
180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/origami/numeric.rb', line 180 def self.parse(stream, parser = nil) #:nodoc: offset = stream.pos if not stream.scan(@@regexp) raise InvalidRealObjectError, "Invalid real number format" end value = stream[2].to_f real = Real.new(value) real.file_offset = offset real end |
Instance Method Details
#to_s ⇒ Object Also known as: to_obfuscated_str
197 198 199 |
# File 'lib/origami/numeric.rb', line 197 def to_s sprintf("%f", self).sub(/\.0*$|(\.\d*[^0])0*$/, '\1') end |