Support numeric inputs for the category
This commit is contained in:
@@ -71,6 +71,10 @@ class TagCategory
|
|||||||
def short_name_regex
|
def short_name_regex
|
||||||
@@short_name_regex ||= short_name_list.join("|")
|
@@short_name_regex ||= short_name_list.join("|")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def category_ids_regex
|
||||||
|
@@category_ids_regex ||= "[#{category_ids.join("")}]"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
extend Mappings
|
extend Mappings
|
||||||
|
|||||||
@@ -87,7 +87,14 @@ class Tag < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def value_for(string)
|
def value_for(string)
|
||||||
TagCategory.mapping[string.to_s.downcase] || 0
|
norm_string = string.to_s.downcase
|
||||||
|
if norm_string =~ /#{TagCategory.category_ids_regex}/
|
||||||
|
norm_string.to_i
|
||||||
|
elsif TagCategory.mapping[string.to_s.downcase]
|
||||||
|
TagCategory.mapping[string.to_s.downcase]
|
||||||
|
else
|
||||||
|
0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user