H
hurcan solter
Although I am a seasoned C/C++ programmer(+10 years), I am relatively
new to the ruby (about 2 days) despite having some reservations(ruby
debugger should be theslowest thing in the world) i am otherwise very
impressed with the language, I intend to use Ruby for some code
generation task ,Everything was going well until i hit that roadblock
class REXML::Element
include TSort
def initialize
@dependencies=[]
end
def tsort_each_node(&block)
@elements.each(&block)
end
def tsort_each_child(node, &block)
@dependencies.each(&block) if @dependencies.size>0
end
end
well as you can see, i need to topologically sort some nodes in an
xml file and there was a module Tsort in the
ruby. from what understand i need to extend to class REXML::Element
to feed Tsort algorithm. I have no problems
with adding the methods but when i feed this new node to tsort() I get
something like this
undefined method `size' for nil:NilClass
H:/ruby/somCompiler.rb:112:in `tsort_each_child'
c:/ruby/lib/ruby/1.8/tsort.rb:204:in
`each_strongly_connected_component_from
c:/ruby/lib/ruby/1.8/tsort.rb:183:in
`each_strongly_connected_component'
c:/ruby/lib/ruby/1.8/rexml/element.rb:939:in `each'
c:/ruby/lib/ruby/1.8/rexml/xpath.rb:53:in `each'
c:/ruby/lib/ruby/1.8/rexml/element.rb:939:in `each'
H:/ruby/somCompiler.rb:109:in `tsort_each_node'
......
or i am missing something terribly here?
Any help would be greatly appreciated..
Hurcan
new to the ruby (about 2 days) despite having some reservations(ruby
debugger should be theslowest thing in the world) i am otherwise very
impressed with the language, I intend to use Ruby for some code
generation task ,Everything was going well until i hit that roadblock
class REXML::Element
include TSort
def initialize
@dependencies=[]
end
def tsort_each_node(&block)
@elements.each(&block)
end
def tsort_each_child(node, &block)
@dependencies.each(&block) if @dependencies.size>0
end
end
well as you can see, i need to topologically sort some nodes in an
xml file and there was a module Tsort in the
ruby. from what understand i need to extend to class REXML::Element
to feed Tsort algorithm. I have no problems
with adding the methods but when i feed this new node to tsort() I get
something like this
undefined method `size' for nil:NilClass
H:/ruby/somCompiler.rb:112:in `tsort_each_child'
c:/ruby/lib/ruby/1.8/tsort.rb:204:in
`each_strongly_connected_component_from
c:/ruby/lib/ruby/1.8/tsort.rb:183:in
`each_strongly_connected_component'
c:/ruby/lib/ruby/1.8/rexml/element.rb:939:in `each'
c:/ruby/lib/ruby/1.8/rexml/xpath.rb:53:in `each'
c:/ruby/lib/ruby/1.8/rexml/element.rb:939:in `each'
H:/ruby/somCompiler.rb:109:in `tsort_each_node'
......
REXML::Element.Is it not possibleFrom what I understand i am unable to add @dependencies array to the
or i am missing something terribly here?
Any help would be greatly appreciated..
Hurcan