Class: Banks::CategoryPolicy
- Inherits:
-
Object
- Object
- Banks::CategoryPolicy
- Defined in:
- lib/banks/utils.rb
Constant Summary collapse
- @@categories =
nil
Class Method Summary collapse
Class Method Details
.categorize(description) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/banks/utils.rb', line 14 def self.categorize description # Lazy read. if @@categories.nil? then data = IO.read "categories.json" @@categories = JSON.parse data end @@categories["categories"].each do |category, payment_types| payment_types.each do |value| if description.upcase.include? value.upcase then return category end end end return "Uncategorized" end |