Class: ActionviewPrecompiler::JRubyASTParser::Node
- Inherits:
-
Object
- Object
- ActionviewPrecompiler::JRubyASTParser::Node
- Defined in:
- lib/actionview_precompiler/ast_parser/jruby.rb
Class Method Summary collapse
Instance Method Summary collapse
- #argument_nodes ⇒ Object
- #array? ⇒ Boolean
- #call? ⇒ Boolean
- #call_method_name ⇒ Object
- #children ⇒ Object
- #fcall? ⇒ Boolean
- #fcall_named?(name) ⇒ Boolean
- #hash? ⇒ Boolean
-
#initialize(node) ⇒ Node
constructor
A new instance of Node.
- #string? ⇒ Boolean
- #symbol? ⇒ Boolean
- #to_hash ⇒ Object
- #to_string ⇒ Object
- #to_symbol ⇒ Object
- #variable_name ⇒ Object
- #variable_reference? ⇒ Boolean
- #vcall? ⇒ Boolean
Constructor Details
#initialize(node) ⇒ Node
Returns a new instance of Node.
12 13 14 |
# File 'lib/actionview_precompiler/ast_parser/jruby.rb', line 12 def initialize(node) @node = node end |
Class Method Details
.wrap(node) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/actionview_precompiler/ast_parser/jruby.rb', line 4 def self.wrap(node) if org::jruby::ast::Node === node new(node) else node end end |
Instance Method Details
#argument_nodes ⇒ Object
50 51 52 53 54 |
# File 'lib/actionview_precompiler/ast_parser/jruby.rb', line 50 def argument_nodes @node.args_node.children.to_a[0...@node.args_node.size].map do |arg| self.class.wrap(arg) end end |
#array? ⇒ Boolean
22 |
# File 'lib/actionview_precompiler/ast_parser/jruby.rb', line 22 def array?; org::jruby::ast::ArrayNode === @node; end |
#call? ⇒ Boolean
38 39 40 |
# File 'lib/actionview_precompiler/ast_parser/jruby.rb', line 38 def call? org::jruby::ast::CallNode === @node; end |
#call_method_name ⇒ Object
46 47 48 |
# File 'lib/actionview_precompiler/ast_parser/jruby.rb', line 46 def call_method_name self.last.first end |
#children ⇒ Object
16 17 18 19 20 |
# File 'lib/actionview_precompiler/ast_parser/jruby.rb', line 16 def children @children ||= @node.child_nodes.map do |child| self.class.wrap(child) end end |
#fcall? ⇒ Boolean
23 |
# File 'lib/actionview_precompiler/ast_parser/jruby.rb', line 23 def fcall?; org::jruby::ast::FCallNode === @node; end |
#fcall_named?(name) ⇒ Boolean
79 80 81 82 83 84 |
# File 'lib/actionview_precompiler/ast_parser/jruby.rb', line 79 def fcall_named?(name) fcall? && @node.name == name && @node.args_node && org::jruby::ast::ArrayNode === @node.args_node end |
#hash? ⇒ Boolean
24 |
# File 'lib/actionview_precompiler/ast_parser/jruby.rb', line 24 def hash?; org::jruby::ast::HashNode === @node; end |
#string? ⇒ Boolean
25 |
# File 'lib/actionview_precompiler/ast_parser/jruby.rb', line 25 def string?; org::jruby::ast::StrNode === @node; end |
#symbol? ⇒ Boolean
26 |
# File 'lib/actionview_precompiler/ast_parser/jruby.rb', line 26 def symbol?; org::jruby::ast::SymbolNode === @node; end |
#to_hash ⇒ Object
56 57 58 59 60 61 |
# File 'lib/actionview_precompiler/ast_parser/jruby.rb', line 56 def to_hash @node.pairs.each_with_object({}) do |pair, object| return nil if pair.key == nil object[self.class.wrap(pair.key)] = self.class.wrap(pair.value) end end |
#to_string ⇒ Object
63 64 65 |
# File 'lib/actionview_precompiler/ast_parser/jruby.rb', line 63 def to_string @node.value end |
#to_symbol ⇒ Object
75 76 77 |
# File 'lib/actionview_precompiler/ast_parser/jruby.rb', line 75 def to_symbol @node.name end |
#variable_name ⇒ Object
42 43 44 |
# File 'lib/actionview_precompiler/ast_parser/jruby.rb', line 42 def variable_name self[0][0] end |
#variable_reference? ⇒ Boolean
28 29 30 31 32 |
# File 'lib/actionview_precompiler/ast_parser/jruby.rb', line 28 def variable_reference? org::jruby::ast::InstVarNode === @node || org::jruby::ast::GlobalVarNode === @node || org::jruby::ast::ClassVarNode === @node end |
#vcall? ⇒ Boolean
34 35 36 |
# File 'lib/actionview_precompiler/ast_parser/jruby.rb', line 34 def vcall? org::jruby::ast::VCallNode === @node; end |