Class: Basic101::BasicInteger
Instance Attribute Summary
Attributes inherited from BasicNumeric
#value
Class Method Summary
collapse
Instance Method Summary
collapse
#<=>, #abs, #cos, #exp, #initialize, #log, #negate, #print_new_line, #print_string, #sgn, #simplest, #sin, #sqr, #tan, #to_b, #to_f, #to_i, #to_numeric
Methods included from BasicMath
basic_math_op
comparison_op
Methods inherited from BasicObject
#eval, #to_numeric, #to_string, type_name, #type_name
Class Method Details
.from_bool(b) ⇒ Object
9
10
11
|
# File 'lib/basic101/basic_integer.rb', line 9
def self.from_bool(b)
new(b ? -1 : 0)
end
|
Instance Method Details
#and(other) ⇒ Object
21
22
23
|
# File 'lib/basic101/basic_integer.rb', line 21
def and(other)
self.class.new(value & other.to_integer.value)
end
|
#not ⇒ Object
29
30
31
|
# File 'lib/basic101/basic_integer.rb', line 29
def not
self.class.new(~value)
end
|
#or(other) ⇒ Object
25
26
27
|
# File 'lib/basic101/basic_integer.rb', line 25
def or(other)
self.class.new(value | other.to_integer.value)
end
|
#str ⇒ Object
38
39
40
|
# File 'lib/basic101/basic_integer.rb', line 38
def str
BasicString.new(@value.to_s)
end
|
#to_float ⇒ Object
17
18
19
|
# File 'lib/basic101/basic_integer.rb', line 17
def to_float
BasicFloat.new(@value)
end
|
#to_integer ⇒ Object
13
14
15
|
# File 'lib/basic101/basic_integer.rb', line 13
def to_integer
self
end
|