Class: W3cApi::Models::Group
- Defined in:
- lib/w3c_api/models/group.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#active? ⇒ Boolean
Check if this group is active.
-
#chairs(client = nil) ⇒ Object
Return chairs for this group.
-
#charters(client = nil) ⇒ Object
Return charters for this group.
-
#created_date ⇒ Object
Parse date strings to Date objects.
- #end_date_parsed ⇒ Object
-
#specifications(client = nil) ⇒ Object
Return specifications in this group.
- #start_date_parsed ⇒ Object
-
#team_contacts(client = nil) ⇒ Object
Return team contacts for this group.
-
#users(client = nil) ⇒ Object
Return users in this group.
Methods inherited from Base
Class Method Details
.from_response(response) ⇒ Object
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/w3c_api/models/group.rb', line 154 def self.from_response(response) transformed_response = transform_keys(response) group = 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 group._links = GroupLinks.new(links) else group.send("#{key}=", value) if group.respond_to?("#{key}=") end end group end |
Instance Method Details
#active? ⇒ Boolean
Check if this group is active
148 149 150 151 152 |
# File 'lib/w3c_api/models/group.rb', line 148 def active? !is_closed && (!end_date || Date.parse(end_date) > Date.today) rescue Date::Error !is_closed end |
#chairs(client = nil) ⇒ Object
Return chairs for this group
115 116 117 118 119 |
# File 'lib/w3c_api/models/group.rb', line 115 def chairs(client = nil) return nil unless client && _links&.chairs client.group_chairs(id) end |
#charters(client = nil) ⇒ Object
Return charters for this group
108 109 110 111 112 |
# File 'lib/w3c_api/models/group.rb', line 108 def charters(client = nil) return nil unless client && _links&.charters client.group_charters(id) end |
#created_date ⇒ Object
Parse date strings to Date objects
129 130 131 132 133 |
# File 'lib/w3c_api/models/group.rb', line 129 def created_date Date.parse(created) if created rescue Date::Error nil end |
#end_date_parsed ⇒ Object
141 142 143 144 145 |
# File 'lib/w3c_api/models/group.rb', line 141 def end_date_parsed Date.parse(end_date) if end_date rescue Date::Error nil end |
#specifications(client = nil) ⇒ Object
Return specifications in this group
101 102 103 104 105 |
# File 'lib/w3c_api/models/group.rb', line 101 def specifications(client = nil) return nil unless client && _links&.specifications client.group_specifications(id) end |
#start_date_parsed ⇒ Object
135 136 137 138 139 |
# File 'lib/w3c_api/models/group.rb', line 135 def start_date_parsed Date.parse(start_date) if start_date rescue Date::Error nil end |
#team_contacts(client = nil) ⇒ Object
Return team contacts for this group
122 123 124 125 126 |
# File 'lib/w3c_api/models/group.rb', line 122 def team_contacts(client = nil) return nil unless client && _links&.team_contacts client.group_team_contacts(id) end |
#users(client = nil) ⇒ Object
Return users in this group
94 95 96 97 98 |
# File 'lib/w3c_api/models/group.rb', line 94 def users(client = nil) return nil unless client && _links&.users client.group_users(id) end |