Class: W3cApi::Models::SpecVersion
- Defined in:
- lib/w3c_api/models/spec_version.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#candidate_recommendation? ⇒ Boolean
Check if this spec version is a Candidate Recommendation.
-
#recommendation? ⇒ Boolean
Check if this spec version is a Recommendation.
-
#specification(client = nil) ⇒ Object
Return the specification this version belongs to.
-
#working_draft? ⇒ Boolean
Check if this spec version is a Working Draft.
Methods inherited from Base
Class Method Details
.from_response(response) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/w3c_api/models/spec_version.rb', line 77 def self.from_response(response) transformed_response = transform_keys(response) spec_version = 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_version._links = SpecVersionLinks.new(links) else spec_version.send("#{key}=", value) if spec_version.respond_to?("#{key}=") end end spec_version end |
Instance Method Details
#candidate_recommendation? ⇒ Boolean
Check if this spec version is a Candidate Recommendation
73 74 75 |
# File 'lib/w3c_api/models/spec_version.rb', line 73 def candidate_recommendation? status == 'CR' end |
#recommendation? ⇒ Boolean
Check if this spec version is a Recommendation
63 64 65 |
# File 'lib/w3c_api/models/spec_version.rb', line 63 def recommendation? status == 'REC' end |
#specification(client = nil) ⇒ Object
Return the specification this version belongs to
53 54 55 56 57 58 59 60 |
# File 'lib/w3c_api/models/spec_version.rb', line 53 def specification(client = nil) return nil unless client && _links&.specification spec_href = _links.specification.href spec_shortname = spec_href.split('/').last client.specification(spec_shortname) end |
#working_draft? ⇒ Boolean
Check if this spec version is a Working Draft
68 69 70 |
# File 'lib/w3c_api/models/spec_version.rb', line 68 def working_draft? status == 'WD' end |