Sha256: d2afc3a30d363b0efb53f543bc0e3a02d6d7eb792f18cee55c37deeacc324d14

Contents?: true

Size: 615 Bytes

Versions: 3

Compression:

Stored size: 615 Bytes

Contents

module Basic101

  class BasicObject

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

    def type_name
      self.class.type_name
    end

    def eval(runtime)
      self
    end

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

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

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

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

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
basic101-0.4.0 lib/basic101/basic_object.rb
basic101-0.2.0 lib/basic101/basic_object.rb
basic101-0.1.0 lib/basic101/basic_object.rb