Class: AddEnding
- Inherits:
-
GrammarTransform
- Object
- GrammarPlugin
- GrammarTransform
- AddEnding
- Defined in:
- lib/ruby_grammar_builder/transforms/add_ending.rb
Overview
Adds the last portion of the scope name to each tag_as if not already present
Instance Method Summary collapse
-
#pre_transform(pattern, options) ⇒ Object
adds the ending to any tag_as in pattern if needed.
Methods inherited from GrammarTransform
Methods inherited from GrammarPlugin
Instance Method Details
#pre_transform(pattern, options) ⇒ Object
adds the ending to any tag_as in pattern if needed
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ruby_grammar_builder/transforms/add_ending.rb', line 10 def pre_transform(pattern, ) return pattern.map { |v| pre_transform(v, ) } if pattern.is_a? Array return pattern unless pattern.is_a? PatternBase ending = [:grammar].ending pattern.transform_tag_as do |tag_as| tag_as.split(" ").map do |tag| next tag if tag.end_with?(ending) tag + "." + ending end.join(" ") end end |