Class: Mutant::AST::Regexp::Transformer::LookupTable::Table Private

Inherits:
Object
  • Object
show all
Includes:
Adamantium
Defined in:
lib/mutant/ast/regexp/transformer.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Table mapping ast types to object information for regexp domain

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.create(*rows) ⇒ Table

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Coerce array of mapping information into structured table

Parameters:

  • (Array(Symbol, Array, Class<Regexp::Expression>))

Returns:



139
140
141
142
143
144
145
# File 'lib/mutant/ast/regexp/transformer.rb', line 139

def self.create(*rows)
  table = rows.map do |ast_type, token, klass|
    [ast_type, Mapping.new(::Regexp::Token.new(*token), klass)]
  end.to_h

  new(table)
end

Instance Method Details

#lookup(type) ⇒ Mapping

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Lookup mapping information given an ast node type

Parameters:

  • type (Symbol)

Returns:



161
162
163
# File 'lib/mutant/ast/regexp/transformer.rb', line 161

def lookup(type)
  table.fetch(type)
end

#typesArray<Symbol>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Types defined by the table

Returns:

  • (Array<Symbol>)


152
153
154
# File 'lib/mutant/ast/regexp/transformer.rb', line 152

def types
  table.keys
end