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
7
8
9
10
|
# File 'lib/basic101/basic_float.rb', line 7
def self.from_s(s)
value = s.to_f
new(value)
end
|
Instance Method Details
#and(other) ⇒ Object
28
29
30
|
# File 'lib/basic101/basic_float.rb', line 28
def and(other)
to_integer.and(other)
end
|
#floor ⇒ Object
36
37
38
|
# File 'lib/basic101/basic_float.rb', line 36
def floor
BasicInteger.new(@value.floor)
end
|
#not ⇒ Object
32
33
34
|
# File 'lib/basic101/basic_float.rb', line 32
def not
to_integer.not
end
|
#or(other) ⇒ Object
24
25
26
|
# File 'lib/basic101/basic_float.rb', line 24
def or(other)
to_integer.or(other)
end
|
#str ⇒ Object
20
21
22
|
# File 'lib/basic101/basic_float.rb', line 20
def str
BasicString.new(@value.to_s)
end
|
#to_float ⇒ Object
16
17
18
|
# File 'lib/basic101/basic_float.rb', line 16
def to_float
self
end
|
#to_integer ⇒ Object
12
13
14
|
# File 'lib/basic101/basic_float.rb', line 12
def to_integer
BasicInteger.new(@value.to_i)
end
|