Class: TinyClassifier::CategoryManager
- Inherits:
-
Object
- Object
- TinyClassifier::CategoryManager
- Defined in:
- lib/tiny-classifier/category-manager.rb
Instance Attribute Summary collapse
-
#chosen ⇒ Object
readonly
Returns the value of attribute chosen.
Instance Method Summary collapse
- #all ⇒ Object
- #basename ⇒ Object
-
#initialize(categories) ⇒ CategoryManager
constructor
A new instance of CategoryManager.
- #normalize(category) ⇒ Object
- #valid?(category) ⇒ Boolean
Constructor Details
#initialize(categories) ⇒ CategoryManager
Returns a new instance of CategoryManager.
20 21 22 23 24 |
# File 'lib/tiny-classifier/category-manager.rb', line 20 def initialize(categories) @categories = categories.strip.split(",") normalize_all clanup end |
Instance Attribute Details
#chosen ⇒ Object (readonly)
Returns the value of attribute chosen.
18 19 20 |
# File 'lib/tiny-classifier/category-manager.rb', line 18 def chosen @chosen end |
Instance Method Details
#all ⇒ Object
26 27 28 |
# File 'lib/tiny-classifier/category-manager.rb', line 26 def all @categories end |
#basename ⇒ Object
35 36 37 |
# File 'lib/tiny-classifier/category-manager.rb', line 35 def basename @categories.join("-").downcase end |
#normalize(category) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/tiny-classifier/category-manager.rb', line 39 def normalize(category) category .downcase .strip .capitalize end |
#valid?(category) ⇒ Boolean
30 31 32 33 |
# File 'lib/tiny-classifier/category-manager.rb', line 30 def valid?(category) category = normalize(category) @categories.include?(category) end |