Class: Basic101::BasicFloat

Inherits:
BasicNumeric show all
Defined in:
lib/basic101/basic_float.rb

Instance Attribute Summary

Attributes inherited from BasicNumeric

#value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BasicNumeric

#<=>, #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

Methods included from BasicComparisons

comparison_op

Methods inherited from BasicObject

#eval, #to_numeric, #to_string, #type_name, type_name

Constructor Details

This class inherits a constructor from Basic101::BasicNumeric

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

#floorObject



38
39
40
# File 'lib/basic101/basic_float.rb', line 38

def floor
  BasicInteger.new(@value.floor)
end

#notObject



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

#strObject



22
23
24
# File 'lib/basic101/basic_float.rb', line 22

def str
  BasicString.new(@value.to_s)
end

#to_floatObject



18
19
20
# File 'lib/basic101/basic_float.rb', line 18

def to_float
  self
end

#to_integerObject



14
15
16
# File 'lib/basic101/basic_float.rb', line 14

def to_integer
  BasicInteger.new(@value.to_i)
end