Class: ActionviewPrecompiler::ASTParser::Node
- Inherits:
-
Object
- Object
- ActionviewPrecompiler::ASTParser::Node
- Defined in:
- lib/actionview_precompiler/ast_parser/jruby.rb,
lib/actionview_precompiler/ast_parser/ruby26.rb
Class Method Summary collapse
Instance Method Summary collapse
- #argument_nodes ⇒ Object
- #array? ⇒ Boolean
- #children ⇒ Object
- #fcall? ⇒ Boolean
- #fcall_named?(name) ⇒ Boolean
- #hash? ⇒ Boolean
-
#initialize(node) ⇒ Node
constructor
A new instance of Node.
- #inspect ⇒ Object
- #string? ⇒ Boolean
- #symbol? ⇒ Boolean
- #to_hash ⇒ Object
- #to_string ⇒ Object
- #to_symbol ⇒ Object
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
28 29 30 31 32 |
# File 'lib/actionview_precompiler/ast_parser/jruby.rb', line 28 def argument_nodes @node.args_node.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 |
#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
48 49 50 51 52 53 |
# File 'lib/actionview_precompiler/ast_parser/jruby.rb', line 48 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 |
#inspect ⇒ Object
22 23 24 |
# File 'lib/actionview_precompiler/ast_parser/ruby26.rb', line 22 def inspect "#<#{self.class} #{@node.inspect}>" 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
34 35 36 37 38 |
# File 'lib/actionview_precompiler/ast_parser/jruby.rb', line 34 def to_hash @node.pairs.each_with_object({}) do |pair, object| object[self.class.wrap(pair.key)] = self.class.wrap(pair.value) end end |
#to_string ⇒ Object
40 41 42 |
# File 'lib/actionview_precompiler/ast_parser/jruby.rb', line 40 def to_string @node.value end |
#to_symbol ⇒ Object
44 45 46 |
# File 'lib/actionview_precompiler/ast_parser/jruby.rb', line 44 def to_symbol @node.name end |