Class: JsRegex::Converter::Base
- Inherits:
-
Object
- Object
- JsRegex::Converter::Base
- Defined in:
- lib/js_regex/converter/base.rb
Overview
Template class. Implement #convert_data in subclasses.
Direct Known Subclasses
AnchorConverter, BackreferenceConverter, ConditionalConverter, EscapeConverter, FreespaceConverter, GroupConverter, LiteralConverter, MetaConverter, PropertyConverter, QuantifierConverter, SetConverter, TypeConverter, UnsupportedTokenConverter
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
- #convert(token_class, subtype, data, start_index, end_index) ⇒ Object
-
#initialize(target, context) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(target, context) ⇒ Base
Returns a new instance of Base.
11 12 13 14 |
# File 'lib/js_regex/converter/base.rb', line 11 def initialize(target, context) @target = target @context = context end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
9 10 11 |
# File 'lib/js_regex/converter/base.rb', line 9 def context @context end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
9 10 11 |
# File 'lib/js_regex/converter/base.rb', line 9 def target @target end |
Instance Method Details
#convert(token_class, subtype, data, start_index, end_index) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/js_regex/converter/base.rb', line 16 def convert(token_class, subtype, data, start_index, end_index) self.token_class = token_class self.subtype = subtype self.data = data self.start_index = start_index self.end_index = end_index result = convert_data target.source << (context.valid? ? result : '') end |