Sha256: eb63fafb0ae169dd51200849a2d24ae2ce9815656a7707cc18cca009ba3c9bcb
Contents?: true
Size: 1.46 KB
Versions: 4
Compression:
Stored size: 1.46 KB
Contents
module ActionviewPrecompiler module ASTParser class Node def self.wrap(node) if org::jruby::ast::Node === node new(node) else node end end def initialize(node) @node = node end def children @children ||= @node.child_nodes.map do |child| self.class.wrap(child) end end def array?; org::jruby::ast::ArrayNode === @node; end def fcall?; org::jruby::ast::FCallNode === @node; end def hash?; org::jruby::ast::HashNode === @node; end def string?; org::jruby::ast::StrNode === @node; end def symbol?; org::jruby::ast::SymbolNode === @node; end def argument_nodes @node.args_node.to_a[0...@node.args_node.size].map do |arg| self.class.wrap(arg) end end def to_hash @node.pairs.each_with_object({}) do |pair, object| object[self.class.wrap(pair.key)] = self.class.wrap(pair.value) end end def to_string @node.value end def to_symbol @node.name end def fcall_named?(name) fcall? && @node.name == name && @node.args_node && org::jruby::ast::ArrayNode === @node.args_node end end def parse(code) Node.wrap(JRuby.parse(code)) end def node?(node) Node === node end def fcall?(node, name) node.fcall_named?(name) end end end
Version data entries
4 entries across 4 versions & 1 rubygems