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



5
6
7
# File 'lib/basic101/basic_object.rb', line 5

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

Instance Method Details

#eval(runtime) ⇒ Object



13
14
15
# File 'lib/basic101/basic_object.rb', line 13

def eval(runtime)
  self
end

#to_floatObject

Raises:



25
26
27
# File 'lib/basic101/basic_object.rb', line 25

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

#to_integerObject

Raises:



21
22
23
# File 'lib/basic101/basic_object.rb', line 21

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

#to_numericObject

Raises:



17
18
19
# File 'lib/basic101/basic_object.rb', line 17

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

#to_stringObject

Raises:



29
30
31
# File 'lib/basic101/basic_object.rb', line 29

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

#type_nameObject



9
10
11
# File 'lib/basic101/basic_object.rb', line 9

def type_name
  self.class.type_name
end