Module: NTEE

Defined in:
lib/ntee.rb,
lib/ntee/version.rb,
lib/ntee/search_dimension.rb

Defined Under Namespace

Classes: Category, FlatDimension, FlatDimensionValue, HierarchicalDimension, HierarchicalDimensionValue

Constant Summary collapse

VERSION =
"0.0.3"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.all_categoriesObject

Returns the value of attribute all_categories.



86
87
88
# File 'lib/ntee.rb', line 86

def all_categories
  @all_categories
end

.root_categoriesObject

Returns the value of attribute root_categories.



86
87
88
# File 'lib/ntee.rb', line 86

def root_categories
  @root_categories
end

Class Method Details

.add_category!(category) ⇒ Object



97
98
99
100
101
102
103
# File 'lib/ntee.rb', line 97

def add_category!(category)
  root_categories[category.code.to_s] = category if category.parent.nil?
  category.subcategories.each do |code, subcategory|
    add_category!(subcategory)
  end
  all_categories[category.code.to_s] = category
end

.category(cat_or_code) ⇒ Object



88
89
90
91
92
93
94
95
# File 'lib/ntee.rb', line 88

def category(cat_or_code)
  case cat_or_code
  when NTEE::Category
    cat_or_code
  else
    all_categories[cat_or_code.to_s]
  end
end