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
7
8
9
|
# File 'lib/basic101/basic_integer.rb', line 7
def self.from_bool(b)
new(b ? -1 : 0)
end
|
Instance Method Details
#and(other) ⇒ Object
19
20
21
|
# File 'lib/basic101/basic_integer.rb', line 19
def and(other)
self.class.new(value & other.to_integer.value)
end
|
#not ⇒ Object
27
28
29
|
# File 'lib/basic101/basic_integer.rb', line 27
def not
self.class.new(~value)
end
|
#or(other) ⇒ Object
23
24
25
|
# File 'lib/basic101/basic_integer.rb', line 23
def or(other)
self.class.new(value | other.to_integer.value)
end
|
#str ⇒ Object
36
37
38
|
# File 'lib/basic101/basic_integer.rb', line 36
def str
BasicString.new(@value.to_s)
end
|
#to_float ⇒ Object
15
16
17
|
# File 'lib/basic101/basic_integer.rb', line 15
def to_float
BasicFloat.new(@value)
end
|
#to_integer ⇒ Object
11
12
13
|
# File 'lib/basic101/basic_integer.rb', line 11
def to_integer
self
end
|