Class: Hyperclient::Curie Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hyperclient/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

Constructor Details

#initialize(curie_hash, entry_point) ⇒ Curie

Initializes a new Curie.

Parameters:

  • curie_hash

    The String with the URI of the curie.

  • entry_point

    The EntryPoint object to inject the configuration.



10
11
12
13
# File 'lib/hyperclient/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.

Parameters:

  • rel

    The String rel to expand.

Returns:

  • a new expanded url.



42
43
44
45
46
# File 'lib/hyperclient/curie.rb', line 42

def expand(rel)
  return rel unless rel && templated?

  href&.gsub('{rel}', rel)
end

#hrefObject

Returns the href property of the Curie.



29
30
31
# File 'lib/hyperclient/curie.rb', line 29

def href
  @curie_hash['href']
end

#inspectObject

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/hyperclient/curie.rb', line 33

def inspect
  "#<#{self.class.name} #{@curie_hash}>"
end

#nameObject

Returns the name property of the Curie.



24
25
26
# File 'lib/hyperclient/curie.rb', line 24

def name
  @curie_hash['name']
end

#templated?Boolean

Indicates if the curie is an URITemplate or a regular URI.

Returns:

  • (Boolean)

    true if it is templated.

  • false if it not templated.



19
20
21
# File 'lib/hyperclient/curie.rb', line 19

def templated?
  !!@curie_hash['templated']
end