lib/boom/list.rb in boom-0.0.5 vs lib/boom/list.rb in boom-0.0.6
- old
+ new
@@ -70,9 +70,22 @@
previous = items.size
items.reject! { |item| item.name == name}
previous != items.size
end
+ # Public: finds an Item by name. If the name is typically truncated, also
+ # allow a search based on that truncated name.
+ #
+ # name - String name of the Item to find
+ #
+ # Returns the found item
+ def find_item(name)
+ items.find do |item|
+ item.name == name ||
+ item.short_name.gsub('…','') == name.gsub('…','')
+ end
+ end
+
# Public: a Hash representation of this List.
#
# Returns a Hash of its own data and its child Items.
def to_hash
{ name => items.collect(&:to_hash) }