Sha256: 4d1d3cab057337667690f46106f34fe9968e085c221ca7c5bac5ce09afe29065

Contents?: true

Size: 795 Bytes

Versions: 5

Compression:

Stored size: 795 Bytes

Contents

# frozen_string_literal: true

module Loxxy
  module Datatype
    # Abstract class that generalizes a value from a Lox built-in data types.
    # An instance acts merely as a wrapper around a Ruby representation
    # of the value.
    class BuiltinDatatype
      # @return [Object] The Ruby representation
      attr_reader :value

      # Constructor. Initialize a Lox value from one of its built-in data type.
      def initialize(aValue)
        @value = validated_value(aValue)
      end

      # Method called from Lox to obtain the text representation of the boolean.
      # @return [String]
      def to_str
        value.to_s # Default implementation...
      end

      protected

      def validated_value(aValue)
        aValue
      end
    end # class
  end # module
end # module

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
loxxy-0.0.16 lib/loxxy/datatype/builtin_datatype.rb
loxxy-0.0.15 lib/loxxy/datatype/builtin_datatype.rb
loxxy-0.0.14 lib/loxxy/datatype/builtin_datatype.rb
loxxy-0.0.13 lib/loxxy/datatype/builtin_datatype.rb
loxxy-0.0.12 lib/loxxy/datatype/builtin_datatype.rb