Class: ApiNavigator::Curie Private
- Inherits:
-
Object
- Object
- ApiNavigator::Curie
- Defined in:
- lib/api_navigator/curie.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Curies are named tokens that you can define in the document and use to express curie relation URIs in a friendlier, more compact fashion.
Instance Method Summary collapse
-
#expand(rel) ⇒ Object
Expands the Curie when is templated with the given variables.
-
#href ⇒ Object
Returns the href property of the Curie.
-
#initialize(curie_hash, entry_point) ⇒ Curie
constructor
Initializes a new Curie.
- #inspect ⇒ Object private
-
#name ⇒ Object
Returns the name property of the Curie.
-
#templated? ⇒ Boolean
Indicates if the curie is an URITemplate or a regular URI.
Constructor Details
#initialize(curie_hash, entry_point) ⇒ Curie
Initializes a new Curie.
10 11 12 13 |
# File 'lib/api_navigator/curie.rb', line 10 def initialize(curie_hash, entry_point) @curie_hash = curie_hash @entry_point = entry_point end |
Instance Method Details
#expand(rel) ⇒ Object
Expands the Curie when is templated with the given variables.
42 43 44 45 |
# File 'lib/api_navigator/curie.rb', line 42 def (rel) return rel unless rel && templated? href.gsub('{rel}', rel) if href end |
#href ⇒ Object
Returns the href property of the Curie.
29 30 31 |
# File 'lib/api_navigator/curie.rb', line 29 def href @curie_hash['href'] end |
#inspect ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
33 34 35 |
# File 'lib/api_navigator/curie.rb', line 33 def inspect "#<#{self.class.name} #{@curie_hash}>" end |
#name ⇒ Object
Returns the name property of the Curie.
24 25 26 |
# File 'lib/api_navigator/curie.rb', line 24 def name @curie_hash['name'] end |
#templated? ⇒ Boolean
Indicates if the curie is an URITemplate or a regular URI.
19 20 21 |
# File 'lib/api_navigator/curie.rb', line 19 def templated? !!@curie_hash['templated'] end |