Class: W3cApi::Models::Serie
- Defined in:
- lib/w3c_api/models/serie.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#current_specification(client = nil) ⇒ Object
Get current specification in this series.
-
#specifications(client = nil) ⇒ Object
Get specifications in this series.
Methods inherited from Base
Class Method Details
.from_response(response) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/w3c_api/models/serie.rb', line 69 def self.from_response(response) transformed_response = transform_keys(response) series = 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 series._links = SerieLinks.new(links) else series.send("#{key}=", value) if series.respond_to?("#{key}=") end end series end |
Instance Method Details
#current_specification(client = nil) ⇒ Object
Get current specification in this series
61 62 63 64 65 66 67 |
# File 'lib/w3c_api/models/serie.rb', line 61 def current_specification(client = nil) return nil unless client && _links&.current_specification href = _links.current_specification.href shortname = href.split('/').last client.specification(shortname) end |
#specifications(client = nil) ⇒ Object
Get specifications in this series
54 55 56 57 58 |
# File 'lib/w3c_api/models/serie.rb', line 54 def specifications(client = nil) return nil unless client && _links&.specifications client.series_specifications(shortname) end |