Class: Creamerscript::Sweeteners::JSArgumentList

Inherits:
Base
  • Object
show all
Defined in:
lib/creamerscript/sweeteners/js_argument_list.rb

Constant Summary

Constants inherited from Base

Base::SYMBOL

Instance Attribute Summary

Attributes inherited from Base

#source, #substitutions

Instance Method Summary collapse

Methods inherited from Base

#call, #initialize, #to_coffee, #token, #tokenize, #type

Constructor Details

This class inherits a constructor from Creamerscript::Sweeteners::Base

Instance Method Details

#patternObject



8
9
10
# File 'lib/creamerscript/sweeteners/js_argument_list.rb', line 8

def pattern
  /\(#{SYMBOL} #{SYMBOL}:(#{SYMBOL},\s*[#{SYMBOL},\s]*)\)/
end

#substitute(source) ⇒ Object



4
5
6
# File 'lib/creamerscript/sweeteners/js_argument_list.rb', line 4

def substitute(source)
  source.gsub!(pattern) { |match| match.gsub($1, tokenize($1)) }
end