Method: FormatEngine::FormatRgx#initialize
- Defined in:
- lib/format_engine/format_spec/rgx.rb
#initialize(format) ⇒ FormatRgx
Setup a variable format specification.
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/format_engine/format_spec/rgx.rb', line 21 def initialize(format) @long_name = format pre, _, post = format.partition('/') @short_name = pre + '/' exp, _, = post.partition(/(?<=[^\\])\// ) opt = (.include?('x') ? Regexp::EXTENDED : 0) | (.include?('i') ? Regexp::IGNORECASE : 0) | (.include?('m') ? Regexp::MULTILINE : 0) @regex = Regexp.new(exp.gsub(/\\\//, '/'), opt) end |