Class: ShafClient::Curie

Inherits:
Link
  • Object
show all
Defined in:
lib/shaf_client/curie.rb

Instance Attribute Summary collapse

Attributes inherited from Link

#templated

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Link

#href, #resolve_templated, #to_h

Constructor Details

#initialize(name:, href:, templated: nil) ⇒ Curie

Returns a new instance of Curie.



19
20
21
22
23
# File 'lib/shaf_client/curie.rb', line 19

def initialize(name:, href:, templated: nil)
  @name = name
  @href = href
  @templated = !!templated
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/shaf_client/curie.rb', line 7

def name
  @name
end

Class Method Details

.from(data) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/shaf_client/curie.rb', line 9

def self.from(data)
  if data.is_a? Array
    data.map do |d|
      new(name: data['name'], href: d['href'], templated: d['templated'])
    end
  else
    new(name: data['name'], href: data['href'], templated: data['templated'])
  end
end