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



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

def !
  !@value
end

#&(other) ⇒ Object



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

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

#^(other) ⇒ Object



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

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

#to_iObject



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

def to_i
  @value ? 1:0
end

#to_intObject



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

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

#valid_type(prm) ⇒ Object



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

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



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

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