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



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

#floorObject



36
37
38
# File 'lib/basic101/basic_float.rb', line 36

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

#notObject



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

#strObject



20
21
22
# File 'lib/basic101/basic_float.rb', line 20

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

#to_floatObject



16
17
18
# File 'lib/basic101/basic_float.rb', line 16

def to_float
  self
end

#to_integerObject



12
13
14
# File 'lib/basic101/basic_float.rb', line 12

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