[macruby-changes] [617] MacRuby/trunk/lib/hotcocoa/mappings/xml_parser.rb

source_changes at macosforge.org source_changes at macosforge.org
Tue Sep 23 16:38:18 PDT 2008


Revision: 617
          http://trac.macosforge.org/projects/ruby/changeset/617
Author:   rich at infoether.com
Date:     2008-09-23 16:38:18 -0700 (Tue, 23 Sep 2008)
Log Message:
-----------
add file key

Modified Paths:
--------------
    MacRuby/trunk/lib/hotcocoa/mappings/xml_parser.rb

Modified: MacRuby/trunk/lib/hotcocoa/mappings/xml_parser.rb
===================================================================
--- MacRuby/trunk/lib/hotcocoa/mappings/xml_parser.rb	2008-09-23 23:38:00 UTC (rev 616)
+++ MacRuby/trunk/lib/hotcocoa/mappings/xml_parser.rb	2008-09-23 23:38:18 UTC (rev 617)
@@ -1,13 +1,14 @@
 HotCocoa::Mappings.map :xml_parser => :NSXMLParser do
 
   def alloc_with_options(options)
-    url = options.delete(:url)
-    data = options.delete(:data)
-    if url
+    if options[:url]
+      url = options.delete(:url)
       url = NSURL.alloc.initWithString(url) if url.is_a?(String)
       NSXMLParser.alloc.initWithContentsOfURL(url)
-    elsif data
-      NSXMLParser.alloc.initWithData(data)
+    elsif options[:file]
+      NSXMLParser.alloc.initWithData(NSData.alloc.initWithContentsOfFile(options.delete(:file)))
+    elsif options[:data]
+      NSXMLParser.alloc.initWithData(options.delete(:data))
     else
       raise "Must provide either :url or :data when constructing an NSXMLParser"
     end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macruby-changes/attachments/20080923/19b8e3d8/attachment.html 


More information about the macruby-changes mailing list