rpl.rb/lib/rpl/types.rb
2022-08-31 11:10:33 +02:00

21 lines
470 B
Ruby

# frozen_string_literal: true
require 'rpl/types/boolean'
require 'rpl/types/name'
require 'rpl/types/list'
require 'rpl/types/string'
require 'rpl/types/program'
require 'rpl/types/numeric'
require 'rpl/types/complex'
module Types
module_function
def new_object( type_class, value )
if type_class.can_parse?( value )
type_class.new( value )
else
RplString.new( "\"Error: cannot create #{type_class} with value #{value}\"" )
end
end
end