lib/latinum/collection.rb in latinum-1.4.1 vs lib/latinum/collection.rb in latinum-1.4.2
- old
+ new
@@ -92,10 +92,18 @@
@resources.each do |key, value|
yield Resource.new(value, key)
end
end
+ def empty?
+ @resources.empty?
+ end
+
+ def include?(key)
+ @resources.include?(key)
+ end
+
# Generate a new collection but ignore zero values.
def compact
collection = self.class.new
@resources.each do |key, value|
@@ -103,8 +111,12 @@
collection.resources[key] = value
end
end
return collection
+ end
+
+ def to_s
+ @resources.map{|name, amount| "#{amount.to_s('F')} #{name}"}.join("; ")
end
end
end