Class: Bit

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

Direct Known Subclasses

FixedBit

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



285
286
287
# File 'lib/primitive_wrapper.rb', line 285

def !
  !@value
end

#&(other) ⇒ Object



277
278
279
# File 'lib/primitive_wrapper.rb', line 277

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

#^(other) ⇒ Object



281
282
283
# File 'lib/primitive_wrapper.rb', line 281

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

#to_iObject



288
289
290
# File 'lib/primitive_wrapper.rb', line 288

def to_i
  @value ? 1:0
end

#to_intObject



291
292
293
# File 'lib/primitive_wrapper.rb', line 291

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

#valid_type(prm) ⇒ Object



266
267
268
269
270
271
272
# File 'lib/primitive_wrapper.rb', line 266

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

#|(other) ⇒ Object



273
274
275
# File 'lib/primitive_wrapper.rb', line 273

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