Module: Ruby2JS::Filter::ActiveFunctions

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

Instance Method Summary collapse

Methods included from SEXP

#S, #s

Instance Method Details

#on_send(node) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ruby2js/filter/active_functions.rb', line 8

def on_send(node)
  target, method, *args = node.children

  if es2015 and method == :blank?
    create_or_update_import("blank$")
    process node.updated :send, [nil, "blank$", target]
  elsif es2015 and method == :present?
    create_or_update_import("present$")
    process node.updated :send, [nil, "present$", target]
  elsif es2015 and method == :presence
    create_or_update_import("presence$")
    process node.updated :send, [nil, "presence$", target]
  elsif es2015 and method == :chomp
    create_or_update_import("chomp$")
    process node.updated :send, [nil, "chomp$", target, *args]
  elsif es2015 and method == :delete_prefix
    create_or_update_import("deletePrefix$")
    process node.updated :send, [nil, "deletePrefix$", target, *args]
  elsif es2015 and method == :delete_suffix
    create_or_update_import("deleteSuffix$")
    process node.updated :send, [nil, "deleteSuffix$", target, *args]
  else
    super
  end
end