Class: FederalRegister::Agency
- Inherits:
-
Base
show all
- Defined in:
- lib/federal_register/agency.rb
Constant Summary
Constants inherited
from Base
Base::INTEGER_CLASS
Instance Attribute Summary
Attributes inherited from Base
#attributes
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
add_attribute, #fetch_full, #full?, #initialize, override_base_uri
Methods inherited from Client
get
Class Method Details
.all(options = {}) ⇒ Object
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/federal_register/agency.rb', line 17
def self.all(options={})
get_options = {}
get_options.merge!(:query => {:fields => options[:fields]}) if options[:fields]
response = get('/agencies.json', get_options).parsed_response
response.map do |hsh|
new(hsh, :full => true)
end
end
|
.find(id_or_slug, options = {}) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/federal_register/agency.rb', line 28
def self.find(id_or_slug, options={})
slug = URI.encode(id_or_slug.to_s)
if options[:fields].present?
response = get("/agencies/#{slug}.json", :query => {:fields => options[:fields]}).parsed_response
if response.is_a?(Hash)
new(response)
else
response.map do |hsh|
new(hsh)
end
end
else
response = get("/agencies/#{slug}.json").parsed_response
if response.is_a?(Hash)
new(response, :full => true)
else
response.map do |hsh|
new(hsh, :full => true)
end
end
end
end
|
.suggestions(args = {}) ⇒ Object
54
55
56
57
58
59
60
|
# File 'lib/federal_register/agency.rb', line 54
def self.suggestions(args={})
response = get("/agencies/suggestions", query: args).parsed_response
response.map do |hsh|
new(hsh, :full => true)
end
end
|
Instance Method Details
#logo_url(size) ⇒ Object
62
63
64
65
66
|
# File 'lib/federal_register/agency.rb', line 62
def logo_url(size)
if attributes.has_key?("logo")
attributes["logo"]["#{size}_url"] || raise("size '#{size}' not a valid image size")
end
end
|