From fb219f82e88568d616dc302f6036ae428ac87853 Mon Sep 17 00:00:00 2001 From: Matchu Date: Sun, 23 Jun 2013 22:58:17 -0700 Subject: [PATCH] sigh, add another special color description format --- app/models/item.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/models/item.rb b/app/models/item.rb index ad823225..b1f2dc1d 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -18,7 +18,7 @@ class Item < ActiveRecord::Base NCRarities = [0, 500] PAINTBRUSH_SET_DESCRIPTION = 'This item is part of a deluxe paint brush set!' SPECIAL_COLOR_DESCRIPTION_REGEX = - /This item is only wearable by Neopets painted ([a-zA-Z]+)\.|WARNING: This [a-zA-Z]+ can be worn by ([a-zA-Z]+) [a-zA-Z]+ ONLY!/ + /This item is only wearable by Neopets painted ([a-zA-Z]+)\.|WARNING: This [a-zA-Z]+ can be worn by ([a-zA-Z]+) [a-zA-Z]+ ONLY!|If your Neopet is not painted ([a-zA-Z]+), it will not be able to wear this item\./ cattr_reader :per_page @@per_page = 30 @@ -168,7 +168,9 @@ class Item < ActiveRecord::Base match = description.match(SPECIAL_COLOR_DESCRIPTION_REGEX) if match - color = match[1] || match[2] + # Since there are multiple formats in the one regex, there are multiple + # possible color name captures. So, take the first non-nil capture. + color = match.captures.detect(&:present?) return Color.find_by_name(color.downcase) end end