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

Constructor Details

This class inherits a constructor from Value

Instance Method Details

#!Object



149
150
151
# File 'lib/primitive_wrapper.rb', line 149

def !
  Bool.new(!@value)
end

#&(other) ⇒ Object



141
142
143
# File 'lib/primitive_wrapper.rb', line 141

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

#^(other) ⇒ Object



145
146
147
# File 'lib/primitive_wrapper.rb', line 145

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

#to_iObject



153
154
155
# File 'lib/primitive_wrapper.rb', line 153

def to_i
  @value ? 1:0
end

#to_intObject



156
157
158
# File 'lib/primitive_wrapper.rb', line 156

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

#valid_type(prm) ⇒ Object



128
129
130
131
132
133
134
135
# File 'lib/primitive_wrapper.rb', line 128

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



137
138
139
# File 'lib/primitive_wrapper.rb', line 137

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