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 + "(?<value>#{Regexp.union(TOKENS)})")
Instance Attribute Summary
Attributes included from Object
#file_offset, #generation, #no, #objstm_offset, #parent
Class Method Summary collapse
Instance Method Summary collapse
- #==(bool) ⇒ Object
- #false? ⇒ Boolean
-
#initialize(value) ⇒ Boolean
constructor
Creates a new Boolean value.
-
#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
#<=>, #cast_to, #copy, #document, #export, included, #indirect?, #indirect_parent, #logicalize, #logicalize!, #native_type, #post_build, #pre_build, #reference, #set_document, #set_indirect, skip_until_next_obj, #solve, #to_o, #type, typeof, #version_required, #xrefs
Constructor Details
#initialize(value) ⇒ Boolean
Creates a new Boolean value.
- value
-
true or false.
40 41 42 43 44 45 46 47 48 |
# File 'lib/origami/boolean.rb', line 40 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 == true) end |
Class Method Details
.parse(stream, _parser = nil) ⇒ Object
:nodoc:
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/origami/boolean.rb', line 54 def self.parse(stream, _parser = nil) #:nodoc: offset = stream.pos if stream.scan(@@regexp).nil? raise InvalidBooleanObjectError end value = (stream['value'] == "true") bool = Boolean.new(value) bool.file_offset = offset bool end |
Instance Method Details
#==(bool) ⇒ Object
84 85 86 |
# File 'lib/origami/boolean.rb', line 84 def ==(bool) @value == bool end |
#to_s ⇒ Object Also known as: to_obfuscated_str
:nodoc:
50 51 52 |
# File 'lib/origami/boolean.rb', line 50 def to_s #:nodoc: super(@value.to_s) end |
#value ⇒ Object
Converts self into a Ruby boolean, that is TrueClass or FalseClass instance.
72 73 74 |
# File 'lib/origami/boolean.rb', line 72 def value @value end |