Class: WBEM::Boolean
Instance Attribute Summary
Attributes inherited from CIMType
Instance Method Summary collapse
- #<=>(obj) ⇒ Object
-
#initialize(arg) ⇒ Boolean
constructor
A new instance of Boolean.
Methods inherited from CIMType
Constructor Details
#initialize(arg) ⇒ Boolean
Returns a new instance of Boolean.
117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/wbem/cim_types.rb', line 117 def initialize(arg) arg = arg.downcase if arg.is_a?(String) if [:true, true, "true"].include?(arg) value = true elsif [:false, false, "false"].include?(arg) value = false else raise TypeError, "Invalid boolean value #{arg}" end super("boolean", value) end |
Instance Method Details
#<=>(obj) ⇒ Object
128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/wbem/cim_types.rb', line 128 def <=>(obj) if obj.is_a?(Boolean) (self.value ^ obj.value) ? 1 : 0 elsif obj == true || obj == false (self.value ^ obj) ? 1 : 0 elsif obj.nil? self.value ? 1 : 0 else 1 end end |