Class: Taoism::Types

Inherits:
Object
  • Object
show all
Defined in:
lib/taoism/types.rb

Class Method Summary collapse

Class Method Details

.numeric?(value) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/taoism/types.rb', line 16

def self.numeric?(value)
  value.is_a?(Integer) or value.is_a?(Float)
end

.typeof(value) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/taoism/types.rb', line 3

def self.typeof(value)
  case value
  when nil         then 'None'
  when true, false then 'Bool'
  when Integer     then 'Int'
  when Array       then 'List'
  when Runtime::Function then 'Fun'
  when Runtime::DataType then value.name
  when Runtime::Instance then value.type.name
  else value.class.name
  end
end