Class: Occi::Core::Kind
- Includes:
- Helpers::Locatable
- Defined in:
- lib/occi/core/kind.rb
Overview
Defines the classification system of the OCCI Core Model. The ‘Kind` instance represents the type identification mechanism for all `Entity` instances present in the model.
Constant Summary
Constants included from Helpers::IdentifierValidator
Helpers::IdentifierValidator::PROHIBITED_SCHEMA_CHARS, Helpers::IdentifierValidator::REGEXP_TERM
Constants included from Helpers::Renderable
Helpers::Renderable::RENDERER_FACTORY_CLASS
Instance Attribute Summary collapse
-
#actions ⇒ Set
list of ‘Action` instances applicable to this `Kind`.
-
#location ⇒ URI
protocol agnostic location of this ‘Kind` instance.
-
#parent ⇒ Kind
previous ‘Kind` in the OCCI kind hierarchy.
Attributes inherited from Category
#attributes, #identifier, #schema, #term, #title
Instance Method Summary collapse
-
#directly_related ⇒ Array
For compatibility reasons, returns the parent instance of this ‘Kind` in an `Array`.
-
#directly_related?(kind) ⇒ TrueClass, FalseClass
Checks whether the given ‘Kind` instance is related to this instance.
-
#hierarchy_root? ⇒ TrueClass, FalseClass
Indicates whether this instance is the base of the OCCI kind hierarchy, i.e.
-
#related ⇒ Array
Transitively returns all predecessors of this ‘Kind` instance in a multi-element `Array`.
-
#related?(kind) ⇒ TrueClass, FalseClass
Checks whether the given ‘Kind` instance is related to this instance.
Methods inherited from Category
#==, #eql?, #hash, #initialize, #to_s, #valid!, #valid?
Methods included from Helpers::IdentifierValidator
#prohibited_chars!, #valid_identifier!, #valid_identifier?, #valid_schema!, #valid_schema?, #valid_term!, #valid_term?, #valid_uri!
Methods included from Helpers::YamlSummoner
#from_yaml, #needs_dereferencing?
Methods included from Helpers::AttributesAccessor
Methods included from Helpers::Renderable
extended, included, #render, #renderer_factory, renderer_factory, renderer_factory_class, #renderer_for
Constructor Details
This class inherits a constructor from Occi::Core::Category
Instance Attribute Details
#actions ⇒ Set
list of ‘Action` instances applicable to this `Kind`
17 18 19 |
# File 'lib/occi/core/kind.rb', line 17 def actions @actions end |
#location ⇒ URI
protocol agnostic location of this ‘Kind` instance
17 18 19 |
# File 'lib/occi/core/kind.rb', line 17 def location @location end |
#parent ⇒ Kind
previous ‘Kind` in the OCCI kind hierarchy
17 18 19 |
# File 'lib/occi/core/kind.rb', line 17 def parent @parent end |
Instance Method Details
#directly_related ⇒ Array
For compatibility reasons, returns the parent instance of this ‘Kind` in an `Array`. For hierarchy roots, returns only an empty `Array`.
62 63 64 |
# File 'lib/occi/core/kind.rb', line 62 def [parent].compact end |
#directly_related?(kind) ⇒ TrueClass, FalseClass
Checks whether the given ‘Kind` instance is related to this instance. The given `Kind` instance must be the immediate predecessor (see `#directly_related`) to succeed.
43 44 45 46 47 |
# File 'lib/occi/core/kind.rb', line 43 def (kind) return false unless kind return true if kind == self .include? kind end |
#hierarchy_root? ⇒ TrueClass, FalseClass
Indicates whether this instance is the base of the OCCI kind hierarchy, i.e. there are no predecessors. This helps to calculate the relationship status correctly, see ‘#related`.
71 72 73 |
# File 'lib/occi/core/kind.rb', line 71 def hierarchy_root? parent.nil? end |
#related ⇒ Array
Transitively returns all predecessors of this ‘Kind` instance in a multi-element `Array`.
53 54 55 56 |
# File 'lib/occi/core/kind.rb', line 53 def return if hierarchy_root? [parent, parent.].flatten.compact end |
#related?(kind) ⇒ TrueClass, FalseClass
Checks whether the given ‘Kind` instance is related to this instance. The given `Kind` instance must be included in the list of predecessors (see `#related`) to succeed.
30 31 32 33 34 |
# File 'lib/occi/core/kind.rb', line 30 def (kind) return false unless kind return true if kind == self .include? kind end |