Module: JsRegex::Target
- Defined in:
- lib/js_regex/target.rb
Constant Summary collapse
Class Method Summary collapse
Class Method Details
.cast(arg) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/js_regex/target.rb', line 8 def self.cast(arg) return ES2009 if arg.nil? normalized_arg = arg.to_s.upcase.sub(/^(ECMASCRIPT|ES|JAVASCRIPT|JS)? ?/, 'ES') return normalized_arg if SUPPORTED.include?(normalized_arg) raise ArgumentError.new( "Unknown target: #{arg.inspect}. Try one of #{SUPPORTED}." ).extend(JsRegex::Error) end |