Module: Occi::Api::Client::Base::CategoryMethods
- Included in:
- ClientBase
- Defined in:
- lib/occi/api/client/base/category_methods.rb
Instance Method Summary collapse
-
#get_category_type_identifier(type) ⇒ String?
Retrieves available category type identifier for the given category type.
-
#get_category_type_identifiers ⇒ Array<String>
Retrieves all available category type identifiers.
-
#get_category_types ⇒ Array<String>
Retrieves all available category types.
Instance Method Details
#get_category_type_identifier(type) ⇒ String?
Retrieves available category type identifier for the given category type.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/occi/api/client/base/category_methods.rb', line 37 def get_category_type_identifier(type) return type if (type =~ URI::ABS_URI) || (type && type.start_with?('/')) cats = @model.categories.to_a.select { |k| k.term == type } tis = cats.collect { |c| c.type_identifier } tis.uniq! if tis.length > 1 raise Occi::Api::Client::Errors::AmbiguousNameError, "Category type #{type.inspect} is ambiguous, use a type identifier!" end tis.first end |
#get_category_type_identifiers ⇒ Array<String>
Retrieves all available category type identifiers.
25 26 27 |
# File 'lib/occi/api/client/base/category_methods.rb', line 25 def get_category_type_identifiers @model.categories.to_a.collect { |category| category.type_identifier } end |
#get_category_types ⇒ Array<String>
Retrieves all available category types.
12 13 14 |
# File 'lib/occi/api/client/base/category_methods.rb', line 12 def get_category_types @model.categories.to_a.collect { |category| category.term } end |