Class: Ruby2JS::Filter::Processor
- Inherits:
-
Parser::AST::Processor
- Object
- Parser::AST::Processor
- Ruby2JS::Filter::Processor
- Defined in:
- lib/ruby2js.rb
Constant Summary collapse
- BINARY_OPERATORS =
Converter::OPERATORS[2..-1].flatten
Instance Method Summary collapse
-
#on_attr(node) ⇒ Object
handle all of the 'invented' ast types.
- #on_autoreturn(node) ⇒ Object
- #on_constructor(node) ⇒ Object
- #on_defp(node) ⇒ Object
- #on_method(node) ⇒ Object
- #on_prop(node) ⇒ Object
- #on_prototype(node) ⇒ Object
-
#on_send(node) ⇒ Object
convert map(&:symbol) to a block.
- #on_sendw(node) ⇒ Object
-
#on_sym(node) ⇒ Object
provide a method so filters can call 'super'.
- #on_undefined?(node) ⇒ Boolean
- #options=(options) ⇒ Object
Instance Method Details
#on_attr(node) ⇒ Object
handle all of the 'invented' ast types
23 |
# File 'lib/ruby2js.rb', line 23 def on_attr(node); on_send(node); end |
#on_autoreturn(node) ⇒ Object
24 |
# File 'lib/ruby2js.rb', line 24 def on_autoreturn(node); on_return(node); end |
#on_constructor(node) ⇒ Object
25 |
# File 'lib/ruby2js.rb', line 25 def on_constructor(node); on_def(node); end |
#on_defp(node) ⇒ Object
26 |
# File 'lib/ruby2js.rb', line 26 def on_defp(node); on_defs(node); end |
#on_method(node) ⇒ Object
27 |
# File 'lib/ruby2js.rb', line 27 def on_method(node); on_send(node); end |
#on_prop(node) ⇒ Object
28 |
# File 'lib/ruby2js.rb', line 28 def on_prop(node); on_array(node); end |
#on_prototype(node) ⇒ Object
29 |
# File 'lib/ruby2js.rb', line 29 def on_prototype(node); on_begin(node); end |
#on_send(node) ⇒ Object
convert map(&:symbol) to a block
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/ruby2js.rb', line 37 def on_send(node) if node.children.length > 2 and node.children.last.type == :block_pass method = node.children.last.children.first.children.last if BINARY_OPERATORS.include? method return on_block s(:block, s(:send, *node.children[0..-2]), s(:args, s(:arg, :a), s(:arg, :b)), s(:return, process(s(:send, s(:lvar, :a), method, s(:lvar, :b))))) else return on_block s(:block, s(:send, *node.children[0..-2]), s(:args, s(:arg, :item)), s(:return, process(s(:attr, s(:lvar, :item), method)))) end end super end |
#on_sendw(node) ⇒ Object
30 |
# File 'lib/ruby2js.rb', line 30 def on_sendw(node); on_send(node); end |
#on_sym(node) ⇒ Object
provide a method so filters can call 'super'
34 |
# File 'lib/ruby2js.rb', line 34 def on_sym(node); node; end |
#on_undefined?(node) ⇒ Boolean
31 |
# File 'lib/ruby2js.rb', line 31 def on_undefined?(node); on_defined?(node); end |
#options=(options) ⇒ Object
18 19 20 |
# File 'lib/ruby2js.rb', line 18 def () = end |