Module: Ruby2JS::Filter::CamelCase
- Includes:
- SEXP
- Defined in:
- lib/ruby2js/filter/camelCase.rb
Constant Summary collapse
- WHITELIST =
%w{ attr_accessor }
Instance Method Summary collapse
- #camelCase(symbol) ⇒ Object
- #on_arg(node) ⇒ Object
- #on_def(node) ⇒ Object
- #on_defs(node) ⇒ Object
- #on_lvar(node) ⇒ Object
- #on_lvasgn(node) ⇒ Object
- #on_optarg(node) ⇒ Object
- #on_send(node) ⇒ Object
- #on_sym(node) ⇒ Object
Methods included from SEXP
Instance Method Details
#camelCase(symbol) ⇒ Object
12 13 14 |
# File 'lib/ruby2js/filter/camelCase.rb', line 12 def camelCase(symbol) symbol.to_s.gsub(/_[a-z]/) {|match| match[1].upcase} end |
#on_arg(node) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/ruby2js/filter/camelCase.rb', line 51 def on_arg(node) if node.children[0] =~ /_.*\w$/ super S(:arg , camelCase(node.children[0]), *node.children[1..-1]) else super end end |
#on_def(node) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/ruby2js/filter/camelCase.rb', line 27 def on_def(node) if node.children[0] =~ /_.*\w$/ super S(:def , camelCase(node.children[0]), *node.children[1..-1]) else super end end |
#on_defs(node) ⇒ Object
75 76 77 78 79 80 81 82 |
# File 'lib/ruby2js/filter/camelCase.rb', line 75 def on_defs(node) if node.children[1] =~ /_.*\w$/ super S(:defs , node.children[0], camelCase(node.children[1]), *node.children[2..-1]) else super end end |
#on_lvar(node) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/ruby2js/filter/camelCase.rb', line 43 def on_lvar(node) if node.children[0] =~ /_.*\w$/ super S(:lvar , camelCase(node.children[0]), *node.children[1..-1]) else super end end |
#on_lvasgn(node) ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/ruby2js/filter/camelCase.rb', line 59 def on_lvasgn(node) if node.children[0] =~ /_.*\w$/ super S(:lvasgn , camelCase(node.children[0]), *node.children[1..-1]) else super end end |
#on_optarg(node) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/ruby2js/filter/camelCase.rb', line 35 def on_optarg(node) if node.children[0] =~ /_.*\w$/ super S(:optarg , camelCase(node.children[0]), *node.children[1..-1]) else super end end |
#on_send(node) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ruby2js/filter/camelCase.rb', line 16 def on_send(node) if node.children[0] == nil and WHITELIST.include? node.children[1].to_s super elsif node.children[1] =~ /_.*\w$/ super S(:send , node.children[0], camelCase(node.children[1]), *node.children[2..-1]) else super end end |
#on_sym(node) ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/ruby2js/filter/camelCase.rb', line 67 def on_sym(node) if node.children[0] =~ /_.*\w$/ super S(:sym , camelCase(node.children[0]), *node.children[1..-1]) else super end end |