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, #type_of?, #unwrap, #val, #val=, #wrapped?, #~

Constructor Details

This class inherits a constructor from Value

Instance Method Details

#!Object



253
254
255
# File 'lib/primitive_wrapper.rb', line 253

def !
  Bool.new(!@value)
end

#&(other) ⇒ Object



245
246
247
# File 'lib/primitive_wrapper.rb', line 245

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

#^(other) ⇒ Object



249
250
251
# File 'lib/primitive_wrapper.rb', line 249

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

#to_iObject



257
258
259
# File 'lib/primitive_wrapper.rb', line 257

def to_i
  @value ? 1:0
end

#to_intObject



260
261
262
# File 'lib/primitive_wrapper.rb', line 260

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

#valid_type(prm) ⇒ Object



232
233
234
235
236
237
238
239
# File 'lib/primitive_wrapper.rb', line 232

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



241
242
243
# File 'lib/primitive_wrapper.rb', line 241

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