Class: Plist::Listener

Inherits:
Object
  • Object
show all
Defined in:
lib/searchlink/plist.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeListener

Returns a new instance of Listener.



22
23
24
25
# File 'lib/searchlink/plist.rb', line 22

def initialize
  @result = nil
  @open = Array.new
end

Instance Attribute Details

#openObject

Returns the value of attribute open.



20
21
22
# File 'lib/searchlink/plist.rb', line 20

def open
  @open
end

#resultObject

Returns the value of attribute result.



20
21
22
# File 'lib/searchlink/plist.rb', line 20

def result
  @result
end

Instance Method Details

#tag_end(name) ⇒ Object



35
36
37
38
39
40
41
42
# File 'lib/searchlink/plist.rb', line 35

def tag_end(name)
  last = @open.pop
  if @open.empty?
    @result = last.to_ruby
  else
    @open.last.children.push last
  end
end

#tag_start(name, attributes) ⇒ Object



27
28
29
# File 'lib/searchlink/plist.rb', line 27

def tag_start(name, attributes)
  @open.push PTag::mappings[name].new
end

#text(contents) ⇒ Object



31
32
33
# File 'lib/searchlink/plist.rb', line 31

def text( contents )
  @open.last.text = contents if @open.last
end