Class: JsRegex::Converter::PropertyConverter
- Defined in:
- lib/js_regex/converter/property_converter.rb
Overview
Template class implementation.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
- .negated_property_replacement(property_string) ⇒ Object
- .property_replacement(property_name, negated = false) ⇒ Object
Methods inherited from Base
Constructor Details
This class inherits a constructor from JsRegex::Converter::Base
Class Method Details
.negated_property_replacement(property_string) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/js_regex/converter/property_converter.rb', line 15 def self.negated_property_replacement(property_string) # take care not to use destructive methods on elements in the map return nil unless property_string if property_string.start_with?('[^') property_string.sub('[^', '[') elsif property_string.start_with?('[') property_string.sub('[', '[^') else # it's an invertable meta char property_string.swapcase end end |
.property_replacement(property_name, negated = false) ⇒ Object
10 11 12 13 |
# File 'lib/js_regex/converter/property_converter.rb', line 10 def self.property_replacement(property_name, negated = false) replacement = JsRegex::PROPERTY_MAP[property_name.downcase.to_sym] negated ? negated_property_replacement(replacement) : replacement end |