Sha256: fbb9ad85a7d1528d94ec66cc7f273e51bba7a4edf013dfd0ac05a5b26e33e9f1

Contents?: true

Size: 573 Bytes

Versions: 25

Compression:

Stored size: 573 Bytes

Contents

# frozen_string_literal: true

module Parser

  class MaxNumparamStack
    attr_reader :stack

    def initialize
      @stack = []
    end

    def has_ordinary_params!
      set(-1)
    end

    def has_ordinary_params?
      top < 0
    end

    def has_numparams?
      top > 0
    end

    def register(numparam)
      set( [top, numparam].max )
    end

    def top
      @stack.last
    end

    def push
      @stack.push(0)
    end

    def pop
      @stack.pop
    end

    private

    def set(value)
      @stack.pop
      @stack.push(value)
    end
  end

end

Version data entries

25 entries across 22 versions & 5 rubygems

Version Path
passbase-1.3.0 vendor/bundle/ruby/2.7.0/gems/parser-2.7.1.4/lib/parser/max_numparam_stack.rb
passbase-1.2.0 vendor/bundle/ruby/2.7.0/gems/parser-2.7.1.4/lib/parser/max_numparam_stack.rb
passbase-1.1.0 vendor/bundle/ruby/2.7.0/gems/parser-2.7.1.4/lib/parser/max_numparam_stack.rb
passbase-1.0.3 vendor/bundle/ruby/2.7.0/gems/parser-2.7.1.4/lib/parser/max_numparam_stack.rb
passbase-1.0.2 vendor/bundle/ruby/2.7.0/gems/parser-2.7.1.4/lib/parser/max_numparam_stack.rb
passbase-1.0.1 vendor/bundle/ruby/2.7.0/gems/parser-2.7.1.4/lib/parser/max_numparam_stack.rb
passbase-1.0.0 vendor/bundle/ruby/2.7.0/gems/parser-2.7.1.4/lib/parser/max_numparam_stack.rb
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/parser-2.7.0.2/lib/parser/max_numparam_stack.rb
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/parser-2.7.1.4/lib/parser/max_numparam_stack.rb
files.com-1.0.1 vendor/bundle/ruby/2.5.0/gems/parser-2.7.1.4/lib/parser/max_numparam_stack.rb
parser-2.7.1.4 lib/parser/max_numparam_stack.rb
parser-2.7.1.3 lib/parser/max_numparam_stack.rb
parser-2.7.1.2 lib/parser/max_numparam_stack.rb
parser-2.7.1.1 lib/parser/max_numparam_stack.rb
talon_one-2.0.0 vendor/bundle/ruby/2.7.0/gems/parser-2.7.1.0/lib/parser/max_numparam_stack.rb
talon_one-2.0.0 vendor/bundle/ruby/2.3.0/gems/parser-2.7.1.0/lib/parser/max_numparam_stack.rb
parser-2.7.1.0 lib/parser/max_numparam_stack.rb
parser-2.7.0.5 lib/parser/max_numparam_stack.rb
parser-2.7.0.4 lib/parser/max_numparam_stack.rb
parser-2.7.0.3 lib/parser/max_numparam_stack.rb