Sha256: a22f452ab1e638fe7c5ad2ff30d67f1bf55421ee526494c958c541fb3c8e6157
Contents?: true
Size: 693 Bytes
Versions: 3
Compression:
Stored size: 693 Bytes
Contents
require_relative 'basic_numeric' module Basic101 class BasicInteger < BasicNumeric def self.from_bool(b) new(b ? -1 : 0) end def to_integer self end def to_float BasicFloat.new(@value) end def and(other) self.class.new(value & other.to_integer.value) end def or(other) self.class.new(value | other.to_integer.value) end def not self.class.new(~value) end def chr raise InvalidArgumentError unless (0..255).include?(@value) BasicString.new(@value.chr) end def str BasicString.new(@value.to_s) end private def format @value.to_s end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
basic101-0.4.0 | lib/basic101/basic_integer.rb |
basic101-0.2.0 | lib/basic101/basic_integer.rb |
basic101-0.1.0 | lib/basic101/basic_integer.rb |