Class: JsRegex::Converter::Context
- Inherits:
-
Object
- Object
- JsRegex::Converter::Context
- Defined in:
- lib/js_regex/converter/context.rb
Overview
Passed among Converters to globalize basic status data.
The Converters themselves are stateless.
Instance Attribute Summary collapse
-
#buffered_set_extractions ⇒ Object
Returns the value of attribute buffered_set_extractions.
-
#buffered_set_members ⇒ Object
Returns the value of attribute buffered_set_members.
-
#captured_groups ⇒ Object
Returns the value of attribute captured_groups.
-
#group_count_changed ⇒ Object
Returns the value of attribute group_count_changed.
-
#group_level ⇒ Object
Returns the value of attribute group_level.
-
#group_level_for_backreference ⇒ Object
Returns the value of attribute group_level_for_backreference.
-
#group_number_for_backreference ⇒ Object
Returns the value of attribute group_number_for_backreference.
-
#negative_lookbehind ⇒ Object
Returns the value of attribute negative_lookbehind.
-
#negative_set_levels ⇒ Object
Returns the value of attribute negative_set_levels.
-
#previous_quantifier_end ⇒ Object
Returns the value of attribute previous_quantifier_end.
-
#previous_quantifier_subtype ⇒ Object
Returns the value of attribute previous_quantifier_subtype.
-
#set_level ⇒ Object
Returns the value of attribute set_level.
Instance Method Summary collapse
- #close_set ⇒ Object
-
#initialize ⇒ Context
constructor
A new instance of Context.
- #negate_set ⇒ Object
- #negative_set?(level = set_level) ⇒ Boolean
- #nested_negation? ⇒ Boolean
-
#open_set ⇒ Object
set context.
- #valid? ⇒ Boolean
Constructor Details
#initialize ⇒ Context
Returns a new instance of Context.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/js_regex/converter/context.rb', line 22 def initialize self.buffered_set_members = [] self.buffered_set_extractions = [] self.captured_groups = 0 self.group_count_changed = false self.group_level = 0 self.negative_lookbehind = false self.negative_set_levels = [] self.set_level = 0 end |
Instance Attribute Details
#buffered_set_extractions ⇒ Object
Returns the value of attribute buffered_set_extractions.
9 10 11 |
# File 'lib/js_regex/converter/context.rb', line 9 def buffered_set_extractions @buffered_set_extractions end |
#buffered_set_members ⇒ Object
Returns the value of attribute buffered_set_members.
9 10 11 |
# File 'lib/js_regex/converter/context.rb', line 9 def buffered_set_members @buffered_set_members end |
#captured_groups ⇒ Object
Returns the value of attribute captured_groups.
9 10 11 |
# File 'lib/js_regex/converter/context.rb', line 9 def captured_groups @captured_groups end |
#group_count_changed ⇒ Object
Returns the value of attribute group_count_changed.
9 10 11 |
# File 'lib/js_regex/converter/context.rb', line 9 def group_count_changed @group_count_changed end |
#group_level ⇒ Object
Returns the value of attribute group_level.
9 10 11 |
# File 'lib/js_regex/converter/context.rb', line 9 def group_level @group_level end |
#group_level_for_backreference ⇒ Object
Returns the value of attribute group_level_for_backreference.
9 10 11 |
# File 'lib/js_regex/converter/context.rb', line 9 def group_level_for_backreference @group_level_for_backreference end |
#group_number_for_backreference ⇒ Object
Returns the value of attribute group_number_for_backreference.
9 10 11 |
# File 'lib/js_regex/converter/context.rb', line 9 def group_number_for_backreference @group_number_for_backreference end |
#negative_lookbehind ⇒ Object
Returns the value of attribute negative_lookbehind.
9 10 11 |
# File 'lib/js_regex/converter/context.rb', line 9 def negative_lookbehind @negative_lookbehind end |
#negative_set_levels ⇒ Object
Returns the value of attribute negative_set_levels.
9 10 11 |
# File 'lib/js_regex/converter/context.rb', line 9 def negative_set_levels @negative_set_levels end |
#previous_quantifier_end ⇒ Object
Returns the value of attribute previous_quantifier_end.
9 10 11 |
# File 'lib/js_regex/converter/context.rb', line 9 def previous_quantifier_end @previous_quantifier_end end |
#previous_quantifier_subtype ⇒ Object
Returns the value of attribute previous_quantifier_subtype.
9 10 11 |
# File 'lib/js_regex/converter/context.rb', line 9 def previous_quantifier_subtype @previous_quantifier_subtype end |
#set_level ⇒ Object
Returns the value of attribute set_level.
9 10 11 |
# File 'lib/js_regex/converter/context.rb', line 9 def set_level @set_level end |
Instance Method Details
#close_set ⇒ Object
60 61 62 |
# File 'lib/js_regex/converter/context.rb', line 60 def close_set self.set_level -= 1 end |
#negate_set ⇒ Object
48 49 50 |
# File 'lib/js_regex/converter/context.rb', line 48 def negate_set self.negative_set_levels |= [set_level] end |
#negative_set?(level = set_level) ⇒ Boolean
52 53 54 |
# File 'lib/js_regex/converter/context.rb', line 52 def negative_set?(level = set_level) negative_set_levels.include?(level) end |
#nested_negation? ⇒ Boolean
56 57 58 |
# File 'lib/js_regex/converter/context.rb', line 56 def nested_negation? set_level > 1 && negative_set? end |
#open_set ⇒ Object
set context
39 40 41 42 43 44 45 46 |
# File 'lib/js_regex/converter/context.rb', line 39 def open_set self.set_level += 1 if set_level == 1 buffered_set_members.clear buffered_set_extractions.clear end self.negative_set_levels -= [set_level] end |
#valid? ⇒ Boolean
33 34 35 |
# File 'lib/js_regex/converter/context.rb', line 33 def valid? !negative_lookbehind end |