class Basic101::BasicInteger
Public Class Methods
from_bool(b)
click to toggle source
# File lib/basic101/basic_integer.rb, line 9 def self.from_bool(b) new(b ? -1 : 0) end
Public Instance Methods
and(other)
click to toggle source
# File lib/basic101/basic_integer.rb, line 21 def and(other) self.class.new(value & other.to_integer.value) end
chr()
click to toggle source
# File lib/basic101/basic_integer.rb, line 33 def chr raise InvalidArgumentError unless (0..255).include?(@value) BasicString.new(@value.chr) end
not()
click to toggle source
# File lib/basic101/basic_integer.rb, line 29 def not self.class.new(~value) end
or(other)
click to toggle source
# File lib/basic101/basic_integer.rb, line 25 def or(other) self.class.new(value | other.to_integer.value) end
str()
click to toggle source
# File lib/basic101/basic_integer.rb, line 38 def str BasicString.new(@value.to_s) end
to_float()
click to toggle source
# File lib/basic101/basic_integer.rb, line 17 def to_float BasicFloat.new(@value) end
to_integer()
click to toggle source
# File lib/basic101/basic_integer.rb, line 13 def to_integer self end
Private Instance Methods
format()
click to toggle source
# File lib/basic101/basic_integer.rb, line 44 def format @value.to_s end