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.
-
#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.
-
#opened_groups ⇒ Object
Returns the value of attribute opened_groups.
-
#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.
21 22 23 24 25 26 27 28 29 |
# File 'lib/js_regex/converter/context.rb', line 21 def initialize self.buffered_set_members = [] self.buffered_set_extractions = [] self.group_level = 0 self.negative_lookbehind = false self.negative_set_levels = [] self.opened_groups = 0 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 |
#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 |
#opened_groups ⇒ Object
Returns the value of attribute opened_groups.
9 10 11 |
# File 'lib/js_regex/converter/context.rb', line 9 def opened_groups @opened_groups 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
58 59 60 |
# File 'lib/js_regex/converter/context.rb', line 58 def close_set self.set_level -= 1 end |
#negate_set ⇒ Object
46 47 48 |
# File 'lib/js_regex/converter/context.rb', line 46 def negate_set self.negative_set_levels |= [set_level] end |
#negative_set?(level = set_level) ⇒ Boolean
50 51 52 |
# File 'lib/js_regex/converter/context.rb', line 50 def negative_set?(level = set_level) negative_set_levels.include?(level) end |
#nested_negation? ⇒ Boolean
54 55 56 |
# File 'lib/js_regex/converter/context.rb', line 54 def nested_negation? set_level > 1 && negative_set? end |
#open_set ⇒ Object
set context
37 38 39 40 41 42 43 44 |
# File 'lib/js_regex/converter/context.rb', line 37 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
31 32 33 |
# File 'lib/js_regex/converter/context.rb', line 31 def valid? !negative_lookbehind end |