Class: LegacyPattern
- Inherits:
-
PatternBase
- Object
- PatternBase
- LegacyPattern
- Defined in:
- lib/ruby_grammar_builder/pattern_variations/legacy_pattern.rb
Overview
LegacyPattern allows for a hash to be treated as a Pattern It implements the minimum required to be sucessfully generated by the grammar
Instance Attribute Summary
Attributes inherited from PatternBase
#arguments, #match, #next_pattern, #original_arguments
Instance Method Summary collapse
-
#__deep_clone__ ⇒ PatternBase
Deeply clone self.
-
#evaluate(*_ignored) ⇒ Object
LegacyPattern cannot be evaluated.
-
#initialize(hash) ⇒ LegacyPattern
constructor
A new instance of LegacyPattern.
-
#insert!(_pattern) ⇒ Object
LegacyPattern cannot be chained.
-
#map! {|self| ... } ⇒ self
Uses a block to transform all Patterns in the list.
-
#run_tests ⇒ Boolean
Runs the unit tests, recursively.
-
#start_pattern ⇒ self
To aid in Linters all Patterns support start_pattern which return the pattern for initial match, for a single match pattern that is itself.
-
#to_tag ⇒ Hash
converts a PatternBase to a Hash representing a textmate rule.
Methods inherited from PatternBase
#==, #__deep_clone_self__, #collect_group_attributes, #convert_group_attributes_to_captures, #convert_includes_to_patterns, #do_add_attributes, #do_collect_self_groups, #do_evaluate_self, #do_get_to_s_name, #each, #eql?, #evaluate_operator, #fixup_regex_references, #groupless, #groupless?, #hash, #insert, #inspect, #lookAheadFor, #lookAheadToAvoid, #lookAround, #lookBehindFor, #lookBehindToAvoid, #map, #map_includes!, #matchResultOf, #maybe, #name, #needs_to_capture?, #oneOf, #oneOrMoreOf, #optimize_outer_group?, #or, #placeholder, #raise_if_regex_has_capture_group, #reTag, #recursivelyMatch, #resolve, #run_self_tests, #self_scramble_references, #single_entity?, #then, #to_r, #to_s, #transform_includes, #transform_tag_as, #zeroOrMoreOf
Constructor Details
#initialize(hash) ⇒ LegacyPattern
Returns a new instance of LegacyPattern.
10 11 12 13 |
# File 'lib/ruby_grammar_builder/pattern_variations/legacy_pattern.rb', line 10 def initialize(hash) super("placeholder") @hash = hash.transform_keys(&:to_sym) end |
Instance Method Details
#__deep_clone__ ⇒ PatternBase
Deeply clone self
58 59 60 |
# File 'lib/ruby_grammar_builder/pattern_variations/legacy_pattern.rb', line 58 def __deep_clone__ self.class.new(@hash) end |
#evaluate(*_ignored) ⇒ Object
LegacyPattern cannot be evaluated
16 17 18 |
# File 'lib/ruby_grammar_builder/pattern_variations/legacy_pattern.rb', line 16 def evaluate(*_ignored) raise "LegacyPattern cannot be used as a part of a Pattern" end |
#insert!(_pattern) ⇒ Object
LegacyPattern cannot be chained
21 22 23 |
# File 'lib/ruby_grammar_builder/pattern_variations/legacy_pattern.rb', line 21 def insert!(_pattern) raise "LegacyPattern cannot be used as a part of a Pattern" end |
#map! {|self| ... } ⇒ self
Uses a block to transform all Patterns in the list
44 45 46 |
# File 'lib/ruby_grammar_builder/pattern_variations/legacy_pattern.rb', line 44 def map!(*) self end |
#run_tests ⇒ Boolean
Runs the unit tests, recursively
37 38 39 |
# File 'lib/ruby_grammar_builder/pattern_variations/legacy_pattern.rb', line 37 def run_tests true end |
#start_pattern ⇒ self
To aid in Linters all Patterns support start_pattern which return the pattern for initial match, for a single match pattern that is itself
51 52 53 |
# File 'lib/ruby_grammar_builder/pattern_variations/legacy_pattern.rb', line 51 def start_pattern "" end |
#to_tag ⇒ Hash
converts a PatternBase to a Hash representing a textmate rule
30 31 32 |
# File 'lib/ruby_grammar_builder/pattern_variations/legacy_pattern.rb', line 30 def to_tag @hash end |