Class: Plistr::Document
- Inherits:
-
Nokogiri::XML::SAX::Document
- Object
- Nokogiri::XML::SAX::Document
- Plistr::Document
- Defined in:
- lib/plistr.rb
Constant Summary collapse
- VALUES =
%w(string real integer date data key)
- BOOLEANS =
%w(true false)
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #characters(string) ⇒ Object
- #end_element(name) ⇒ Object
- #start_document ⇒ Object
- #start_element(name, attributes) ⇒ Object
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
10 11 12 |
# File 'lib/plistr.rb', line 10 def value @value end |
Instance Method Details
#characters(string) ⇒ Object
31 32 33 |
# File 'lib/plistr.rb', line 31 def characters(string) @text.concat string end |
#end_element(name) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/plistr.rb', line 35 def end_element(name) return unless value = @stack.pop if value.is_a?(Value) value.text.concat @text.strip end @text = "" if @stack.last.is_a?(Struct) @stack.last.push value elsif @stack.empty? @value = value.parse end end |
#start_document ⇒ Object
12 13 14 15 |
# File 'lib/plistr.rb', line 12 def start_document @stack = [] @text = "" end |
#start_element(name, attributes) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/plistr.rb', line 17 def start_element(name, attributes) return if name == "plist" if VALUES.include?(name) @stack.push Value.new(name) elsif BOOLEANS.include?(name) @stack.push Boolean.new(name) elsif name == "array" @stack.push Array.new elsif name == "dict" @stack.push Dict.new end end |