Skip to content

Commit

Permalink
Just work with the first item instead of a list
Browse files Browse the repository at this point in the history
This was originally done as a list just in case that was ever useful, but,
well, it seems silly to have code for a case that's never used.
  • Loading branch information
scotchi committed Oct 10, 2012
1 parent 0088d3b commit 0ad066a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Ruby/lib/directededge/item.rb
Expand Up @@ -36,7 +36,7 @@ def initialize(database, id)
end

def load
data = XML.parse(resource.get).first
data = XML.parse(resource.get)
@data.keys.each { |key| @data[key].set(data[key]) }
self
end
Expand All @@ -51,7 +51,7 @@ def save
private

def cached?
@data.first.last.cached?
@data.values.first.cached?
end

def queued?(add_or_remove)
Expand Down
19 changes: 9 additions & 10 deletions Ruby/lib/directededge/xml.rb
Expand Up @@ -28,16 +28,15 @@ module DirectedEdge
class XML
def self.parse(text)
doc = LibXML::XML::Parser.string(text).parse
doc.find('//item').map do |item|
{
:id => item['id'],
:links => item.find('//link').map { |l| Link.new(item['id'], l.first.to_s, l) },
:tags => Reader.list(item, '//tag'),
:preselcted => Reader.list(item, '//preselected'),
:blacklisted => Reader.list(item, '//blacklisted'),
:properties => Hash[item.find('//property').map { |p| [ p['name'], p.first.to_s ] }]
}
end
item = doc.find('//item').first
{
:id => item['id'],
:links => item.find('//link').map { |l| Link.new(item['id'], l.first.to_s, l) },
:tags => Reader.list(item, '//tag'),
:preselcted => Reader.list(item, '//preselected'),
:blacklisted => Reader.list(item, '//blacklisted'),
:properties => Hash[item.find('//property').map { |p| [ p['name'], p.first.to_s ] }]
}
end

def self.generate(item, with_root = true)
Expand Down

0 comments on commit 0ad066a

Please sign in to comment.