Sha256: fb68614da0a7cf674037aaf4dba94ffe190e9a013ce05b3ca27611713dae53ac

Contents?: true

Size: 754 Bytes

Versions: 1

Compression:

Stored size: 754 Bytes

Contents

module Parser
  module Source

    ##
    # @api public
    #
    class Map
      attr_reader :expression

      def initialize(expression)
        @expression = expression

        freeze
      end

      def line
        @expression.line
      end

      def column
        @expression.column
      end

      def with_expression(expression_l)
        with { |map| map.update_expression(expression_l) }
      end

      def to_hash
        Hash[instance_variables.map do |ivar|
          [ ivar[1..-1].to_sym, instance_variable_get(ivar) ]
        end]
      end

      protected

      def with(&block)
        dup.tap(&block).freeze
      end

      def update_expression(expression_l)
        @expression = expression_l
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
parser-2.0.0.pre3 lib/parser/source/map.rb