Class: Origami::Boolean
- Inherits:
-
Object
- Object
- Origami::Boolean
- Includes:
- Object
- Defined in:
- lib/origami/boolean.rb,
lib/origami/obfuscation.rb
Overview
Class representing a Boolean Object. A Boolean Object can be true or false.
Constant Summary collapse
- TOKENS =
:nodoc:
[ %w{ true false }
- @@regexp =
Regexp.new(WHITESPACES + "(#{TOKENS.first.join('|')})")
Instance Attribute Summary
Attributes included from Object
#file_offset, #generation, #no, #objstm_offset, #parent
Class Method Summary collapse
-
.parse(stream) ⇒ Object
:nodoc:.
Instance Method Summary collapse
- #==(bool) ⇒ Object
- #false? ⇒ Boolean
-
#initialize(value) ⇒ Boolean
constructor
Creates a new Boolean value.
- #real_type ⇒ Object
-
#to_s ⇒ Object
(also: #to_obfuscated_str)
:nodoc:.
- #true? ⇒ Boolean
-
#value ⇒ Object
Converts self into a Ruby boolean, that is TrueClass or FalseClass instance.
Methods included from Object
#<=>, #copy, #indirect_parent, #is_indirect?, #pdf, #pdf_version_required, #post_build, #pre_build, #reference, #set_indirect, #set_pdf, #size, skip_until_next_obj, #solve, #to_o, #type, typeof, #xrefs
Constructor Details
#initialize(value) ⇒ Boolean
Creates a new Boolean value.
- value
-
true or false.
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/origami/boolean.rb', line 47 def initialize(value) unless value.is_a?(TrueClass) or value.is_a?(FalseClass) raise TypeError, "Expected type TrueClass or FalseClass, received #{value.class}." end super() @value = (value == nil || value == false) ? false : true end |
Class Method Details
.parse(stream) ⇒ Object
:nodoc:
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/origami/boolean.rb', line 62 def self.parse(stream) #:nodoc: offset = stream.pos if stream.scan(@@regexp).nil? raise InvalidBooleanObjectError end value = stream[2] == "true" ? true : false bool = Boolean.new(value) bool.file_offset = offset bool end |
Instance Method Details
#==(bool) ⇒ Object
95 96 97 |
# File 'lib/origami/boolean.rb', line 95 def ==(bool) @value == bool end |
#to_s ⇒ Object Also known as: to_obfuscated_str
:nodoc:
58 59 60 |
# File 'lib/origami/boolean.rb', line 58 def to_s #:nodoc: super(@value.to_s) end |
#value ⇒ Object
Converts self into a Ruby boolean, that is TrueClass or FalseClass instance.
81 82 83 |
# File 'lib/origami/boolean.rb', line 81 def value @value end |