Sha256: 58724feaaca7de7a44a498fee2dabf1242f06e684cae3a663afb2977ccc98060

Contents?: true

Size: 633 Bytes

Versions: 10

Compression:

Stored size: 633 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

    def to_s
      inspect
    end

    def to_readable_bytecode
      inspect
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
grumlin-0.15.6 lib/grumlin/typed_value.rb
grumlin-0.15.4 lib/grumlin/typed_value.rb
grumlin-0.15.3 lib/grumlin/typed_value.rb
grumlin-0.15.2 lib/grumlin/typed_value.rb
grumlin-0.15.1 lib/grumlin/typed_value.rb
grumlin-0.15.0 lib/grumlin/typed_value.rb
grumlin-0.14.5 lib/grumlin/typed_value.rb
grumlin-0.14.4 lib/grumlin/typed_value.rb
grumlin-0.14.3 lib/grumlin/typed_value.rb
grumlin-0.14.2 lib/grumlin/typed_value.rb