Class: W3cApi::Models::Specification

Inherits:
Base
  • Object
show all
Defined in:
lib/w3c_api/models/specification.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

transform_keys

Class Method Details

.from_response(response) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/w3c_api/models/specification.rb', line 60

def self.from_response(response)
  transformed_response = transform_keys(response)

  spec = new
  transformed_response.each do |key, value|
    case key
    when :_links
      links = value.each_with_object({}) do |(link_name, link_data), acc|
        acc[link_name] = Link.new(href: link_data[:href], title: link_data[:title])
      end
      spec._links = SpecificationLinks.new(links)
    else
      spec.send("#{key}=", value) if spec.respond_to?("#{key}=")
    end
  end
  spec
end

Instance Method Details

#versions(client = nil) ⇒ Object

Return versions of this specification



54
55
56
57
58
# File 'lib/w3c_api/models/specification.rb', line 54

def versions(client = nil)
  return nil unless client && shortname

  client.specification_versions(shortname)
end