Sha256: d0c5ea9ed92fa81947c87b4c36579b1ed9ab560c2a043bbe4ec9a1c710758970

Contents?: true

Size: 611 Bytes

Versions: 4

Compression:

Stored size: 611 Bytes

Contents

# frozen_string_literal: true

module Gherkin
  class AstNode
    attr_reader :rule_type

    def initialize(rule_type)
      @rule_type = rule_type
      @_sub_items = Hash.new { |hash, key| hash[key] = [] } # returns [] for unknown key
    end

    def add(rule_type, obj)
      @_sub_items[rule_type].push(obj)
    end

    def get_single(rule_type)
      @_sub_items[rule_type].first
    end

    def get_items(rule_type)
      @_sub_items[rule_type]
    end

    def get_token(token_type)
      get_single(token_type)
    end

    def get_tokens(token_type)
      @_sub_items[token_type]
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cucumber-gherkin-30.0.4 lib/gherkin/ast_node.rb
cucumber-gherkin-30.0.3 lib/gherkin/ast_node.rb
cucumber-gherkin-30.0.2 lib/gherkin/ast_node.rb
cucumber-gherkin-30.0.1 lib/gherkin/ast_node.rb