On 06/08/13 08:35, Renato Co wrote:
> All I want to do, is to create a new variable called data_dfp inside the
> class, and be able to set/get it's value from outside
>
> require 'nokogiri'
> class MyDocument < Nokogiri::XML::SAX::Document
>    attr_accessor :data_dfp
>
>    def start_element(name, attrs = [])
>      puts "#{name}"
>    end
> end

>
> parser = Nokogiri::XML::SAX::Parser.new(MyDocument.new)
^^ I'm not sure what this is supposed to mean.

Have you tried simply:

parser = MyDocument.new

I'm not familiar with nokogiri, is it supposed to take something in its 
constructor?

> parser.data_dfp = 4
> puts parser.data_dfp
>
> Error
> nokoteste.rb:12:in `<main>': undefined method `data_dfp=' for
> #<Nokogiri::XML::SAX::Parser:0x007fcc1413bea0> (NoMethodError)
>
>
> Whats the right way of doing this?
>

Sam