Class: Stix2::Boolean
- Inherits:
-
Object
- Object
- Stix2::Boolean
- Defined in:
- lib/stix2/boolean.rb
Instance Method Summary collapse
-
#initialize(value) ⇒ Boolean
constructor
A new instance of Boolean.
- #method_missing(m, *args, &block) ⇒ Object
Constructor Details
#initialize(value) ⇒ Boolean
Returns a new instance of Boolean.
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/stix2/boolean.rb', line 3 def initialize(value) case value when String @value = !!(value =~ /\A(true|t|yes|y|1)\z/i) when Numeric @value = !value.to_i.zero? else @value = (value == true) end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
14 15 16 |
# File 'lib/stix2/boolean.rb', line 14 def method_missing(m, *args, &block) @value.send(m, *args, &block) end |