class Minireq::Core::Node
Attributes
attributes[R]
id[R]
items[R]
parent[RW]
title[R]
Public Class Methods
new(id, options = {})
click to toggle source
# File lib/minireq/core/node.rb, line 18 def initialize(id, options = {}) @parent = nil @items = [] @attributes = {} @id = id @title = options[:title] options.delete(:title) @attributes.merge!(options) end
Public Instance Methods
get_ids()
click to toggle source
# File lib/minireq/core/node.rb, line 41 def get_ids to_a.inject([]){|a, i| a << i.id} end
level()
click to toggle source
TODO: 0 add level
method to support full output
# File lib/minireq/core/node.rb, line 46 def level result = 1 parent = @parent until parent.nil? result += 1 parent = parent.parent end result end
to_a()
click to toggle source
# File lib/minireq/core/node.rb, line 35 def to_a a = [] visit{|n| a << n} a end
visit() { |self| ... }
click to toggle source
# File lib/minireq/core/node.rb, line 29 def visit(&block) return unless block_given? yield(self) @items.each { |n| n.visit(&block) } end