Class: JsRegex::Conversion
- Inherits:
-
Object
- Object
- JsRegex::Conversion
- Defined in:
- lib/js_regex/conversion.rb
Overview
This class acts as a facade, creating specific Converters and passing Regexp::Scanner tokens to them, reusing Converters as needed.
::of returns a source String, options String, and warnings Array.
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#converters ⇒ Object
readonly
Returns the value of attribute converters.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#ruby_regex ⇒ Object
readonly
Returns the value of attribute ruby_regex.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#warnings ⇒ Object
readonly
Returns the value of attribute warnings.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(ruby_regex) ⇒ Conversion
constructor
A new instance of Conversion.
Constructor Details
#initialize(ruby_regex) ⇒ Conversion
Returns a new instance of Conversion.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/js_regex/conversion.rb', line 16 def initialize(ruby_regex) self.ruby_regex = ruby_regex self.context = Converter::Context.new self.converters = {} self.source = ''.dup self. = ''.dup self.warnings = [] convert_source perform_sanity_check end |
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
14 15 16 |
# File 'lib/js_regex/conversion.rb', line 14 def context @context end |
#converters ⇒ Object
Returns the value of attribute converters.
14 15 16 |
# File 'lib/js_regex/conversion.rb', line 14 def converters @converters end |
#options ⇒ Object
Returns the value of attribute options.
14 15 16 |
# File 'lib/js_regex/conversion.rb', line 14 def @options end |
#ruby_regex ⇒ Object
Returns the value of attribute ruby_regex.
14 15 16 |
# File 'lib/js_regex/conversion.rb', line 14 def ruby_regex @ruby_regex end |
#source ⇒ Object
Returns the value of attribute source.
14 15 16 |
# File 'lib/js_regex/conversion.rb', line 14 def source @source end |
#warnings ⇒ Object
Returns the value of attribute warnings.
14 15 16 |
# File 'lib/js_regex/conversion.rb', line 14 def warnings @warnings end |
Class Method Details
.of(ruby_regex) ⇒ Object
31 32 33 34 |
# File 'lib/js_regex/conversion.rb', line 31 def self.of(ruby_regex) conversion = new(ruby_regex) [conversion.source, conversion., conversion.warnings] end |