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.



24
25
26
27
# File 'lib/searchlink/plist.rb', line 24

def initialize
  @result = nil
  @open = []
end

Instance Attribute Details

#openObject

Returns the value of attribute open.



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

def open
  @open
end

#resultObject

Returns the value of attribute result.



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

def result
  @result
end

Instance Method Details

#tag_end(_name) ⇒ Object



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

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



29
30
31
# File 'lib/searchlink/plist.rb', line 29

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

#text(contents) ⇒ Object



33
34
35
# File 'lib/searchlink/plist.rb', line 33

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