Class: Basic101::BasicFloat
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_s(s) ⇒ Object
9
10
11
12
|
# File 'lib/basic101/basic_float.rb', line 9
def self.from_s(s)
value = s.to_f
new(value)
end
|
Instance Method Details
#and(other) ⇒ Object
30
31
32
|
# File 'lib/basic101/basic_float.rb', line 30
def and(other)
to_integer.and(other)
end
|
#floor ⇒ Object
38
39
40
|
# File 'lib/basic101/basic_float.rb', line 38
def floor
BasicInteger.new(@value.floor)
end
|
#not ⇒ Object
34
35
36
|
# File 'lib/basic101/basic_float.rb', line 34
def not
to_integer.not
end
|
#or(other) ⇒ Object
26
27
28
|
# File 'lib/basic101/basic_float.rb', line 26
def or(other)
to_integer.or(other)
end
|
#str ⇒ Object
22
23
24
|
# File 'lib/basic101/basic_float.rb', line 22
def str
BasicString.new(@value.to_s)
end
|
#to_float ⇒ Object
18
19
20
|
# File 'lib/basic101/basic_float.rb', line 18
def to_float
self
end
|
#to_integer ⇒ Object
14
15
16
|
# File 'lib/basic101/basic_float.rb', line 14
def to_integer
BasicInteger.new(@value.to_i)
end
|