Class: Basic101::BasicObject

Inherits:
Object
  • Object
show all
Defined in:
lib/basic101/basic_object.rb

Direct Known Subclasses

BasicNumeric, BasicString

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.type_nameObject



7
8
9
# File 'lib/basic101/basic_object.rb', line 7

def self.type_name
  name.split('::').last.gsub(/^Basic/, '').downcase
end

Instance Method Details

#eval(runtime) ⇒ Object



15
16
17
# File 'lib/basic101/basic_object.rb', line 15

def eval(runtime)
  self
end

#to_floatObject

Raises:



27
28
29
# File 'lib/basic101/basic_object.rb', line 27

def to_float
  raise TypeError, "#{type_name} cannot be converted to float"
end

#to_integerObject

Raises:



23
24
25
# File 'lib/basic101/basic_object.rb', line 23

def to_integer
  raise TypeError, "#{type_name} cannot be converted to integer"
end

#to_numericObject

Raises:



19
20
21
# File 'lib/basic101/basic_object.rb', line 19

def to_numeric
  raise TypeError, "#{type_name} cannot be converted to numeric"
end

#to_stringObject

Raises:



31
32
33
# File 'lib/basic101/basic_object.rb', line 31

def to_string
  raise TypeError, "#{type_name} cannot be converted to string"
end

#type_nameObject



11
12
13
# File 'lib/basic101/basic_object.rb', line 11

def type_name
  self.class.type_name
end