Class: Bool

Inherits:
Value show all
Defined in:
lib/primitive_wrapper.rb

Direct Known Subclasses

Bit

Instance Method Summary collapse

Methods inherited from Value

#!=, #==, #ensure_valid, #freeze, freeze_raise?, ignore_on_freeze, #initialize, #inspect, #prim_value, raise_on_freeze, #replace, #to_s, #to_wrapper, #type_of?, #unwrap, #val, #val=, #wrapped?, #~

Constructor Details

This class inherits a constructor from Value

Instance Method Details

#!Object



229
230
231
# File 'lib/primitive_wrapper.rb', line 229

def !
  Bool.new(!@value)
end

#&(other) ⇒ Object



221
222
223
# File 'lib/primitive_wrapper.rb', line 221

def &(other)
  Bool.new(@value & other.prim_value)
end

#^(other) ⇒ Object



225
226
227
# File 'lib/primitive_wrapper.rb', line 225

def ^(other)
  Bool.new(@value ^ other.prim_value)
end

#to_iObject



233
234
235
# File 'lib/primitive_wrapper.rb', line 233

def to_i
  @value ? 1:0
end

#to_intObject



236
237
238
# File 'lib/primitive_wrapper.rb', line 236

def to_int
  Int.new(@value ? 1:0)
end

#valid_type(prm) ⇒ Object



208
209
210
211
212
213
214
215
# File 'lib/primitive_wrapper.rb', line 208

def valid_type(prm)
  return true if prm.kind_of? TrueClass
  return true if prm.kind_of? FalseClass
  return true if prm.kind_of? TrueW
  return true if prm.kind_of? FalseW
  return true if prm.kind_of? Bool
  false
end

#|(other) ⇒ Object



217
218
219
# File 'lib/primitive_wrapper.rb', line 217

def |(other)
  Bool.new(@value | other.prim_value)
end