class Nasl::Tree
Public Class Methods
new(parent=nil)
click to toggle source
# File lib/nasl/parser/tree.rb, line 40 def initialize(parent=nil) @parent = parent @all = {} end
Public Instance Methods
all(cls)
click to toggle source
# File lib/nasl/parser/tree.rb, line 31 def all(cls) (@all[Nasl.const_get(cls).to_s] ||= []) end
register(node)
click to toggle source
# File lib/nasl/parser/tree.rb, line 35 def register(node) (@all[node.class.name] ||= []) << node @parent.register(node) unless @parent.nil? end
to_s()
click to toggle source
# File lib/nasl/parser/tree.rb, line 45 def to_s text = '' xml = Builder::XmlMarkup.new(:target=>text, :indent=>2) if empty? xml.tree else xml.tree { self.map { |node| node.to_xml(xml) } } end text end