Sha256: 989d9e1b6291330b19bf1579a83957d846ff6c23f505cfb30d89c7beb2c62b71

Contents?: true

Size: 607 Bytes

Versions: 11

Compression:

Stored size: 607 Bytes

Contents

# frozen_string_literal: true

module Grumlin
  class TypedValue
    attr_reader :type, :value

    def initialize(type: nil, value: nil)
      @type = type
      @value = value
    end

    def to_bytecode
      @to_bytecode ||= if type.nil?
                         value
                       else
                         {
                           "@type": "g:#{type}",
                           "@value": value
                         }
                       end
    end

    def inspect
      "<#{type}.#{value}>"
    end
    alias to_s inspect
    alias to_readable_bytecode inspect
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
grumlin-0.14.1 lib/grumlin/typed_value.rb
grumlin-0.14.0 lib/grumlin/typed_value.rb
grumlin-0.13.1 lib/grumlin/typed_value.rb
grumlin-0.13.0 lib/grumlin/typed_value.rb
grumlin-0.12.5 lib/grumlin/typed_value.rb
grumlin-0.12.4 lib/grumlin/typed_value.rb
grumlin-0.12.3 lib/grumlin/typed_value.rb
grumlin-0.12.2 lib/grumlin/typed_value.rb
grumlin-0.12.1 lib/grumlin/typed_value.rb
grumlin-0.12.0 lib/grumlin/typed_value.rb
grumlin-0.11.0 lib/grumlin/typed_value.rb