Module: Ruby2JS::Filter::JQuery

Includes:
SEXP
Defined in:
lib/ruby2js/filter/jquery.rb

Instance Method Summary collapse

Methods included from SEXP

#s

Instance Method Details

#initializeObject



8
9
10
# File 'lib/ruby2js/filter/jquery.rb', line 8

def initialize
  @each = true # disable each mapping, see functions filter
end

#on_gvar(node) ⇒ Object

map $$ to $



13
14
15
16
17
18
19
# File 'lib/ruby2js/filter/jquery.rb', line 13

def on_gvar(node)
  if node.children[0] == :$$
    node.updated nil, ['$']
  else
    super
  end
end

#on_send(node) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ruby2js/filter/jquery.rb', line 21

def on_send(node)
  if node.children[1] == :call
    target = process(node.children.first)
    if target.type == :gvar and target.children == ['$']
      s(:send, nil, '$', *process_all(node.children[2..-1]))
    else
      super
    end
  else
    super
  end
end