class Propublica::Nonprofits::Organization
Attributes
attributes[R]
full_request_made[RW]
Public Class Methods
new(attributes)
click to toggle source
# File lib/propublica/nonprofits/organization.rb, line 4 def initialize(attributes) @attributes = attributes end
Public Instance Methods
api_version()
click to toggle source
# File lib/propublica/nonprofits/organization.rb, line 32 def api_version ensure_full_request! @api_version ||= attributes["api_version"] end
basic()
click to toggle source
# File lib/propublica/nonprofits/organization.rb, line 8 def basic @basic ||= BasicParser.new(attributes["basic"]) end
data_source()
click to toggle source
# File lib/propublica/nonprofits/organization.rb, line 27 def data_source ensure_full_request! @data_source ||= attributes["data_source"] end
details()
click to toggle source
# File lib/propublica/nonprofits/organization.rb, line 12 def details ensure_full_request! @details ||= DetailsParser.new(attributes["organization"]) end
error()
click to toggle source
# File lib/propublica/nonprofits/organization.rb, line 37 def error ensure_full_request! @error ||= attributes["error"] || "" end
error?()
click to toggle source
# File lib/propublica/nonprofits/organization.rb, line 42 def error? !error.empty? end
filings_with_data()
click to toggle source
# File lib/propublica/nonprofits/organization.rb, line 17 def filings_with_data ensure_full_request! @filings_with_data ||= attributes["filings_with_data"].map { |f| FilingsWithDataParser.new(f) } end
filings_without_data()
click to toggle source
# File lib/propublica/nonprofits/organization.rb, line 22 def filings_without_data ensure_full_request! @filings_without_data ||= attributes["filings_without_data"].map { |f| FilingsWithoutDataParser.new(f) } end
Private Instance Methods
ein()
click to toggle source
# File lib/propublica/nonprofits/organization.rb, line 68 def ein @attributes.dig("organization", "ein") || self.basic.ein end
ensure_full_request!()
click to toggle source
# File lib/propublica/nonprofits/organization.rb, line 55 def ensure_full_request! return if full_request_made? self.full_request_made = (attributes.keys & required_keys) == required_keys return if full_request_made? fetch_full_request! end
fetch_full_request!()
click to toggle source
# File lib/propublica/nonprofits/organization.rb, line 72 def fetch_full_request! # Fetch all attributes and merge with what we have now new_attrs = Propublica::Nonprofits.find_attributes(ein) attributes.merge!(new_attrs) self.full_request_made = true end
full_request_made?()
click to toggle source
# File lib/propublica/nonprofits/organization.rb, line 51 def full_request_made? !!full_request_made end
required_keys()
click to toggle source
# File lib/propublica/nonprofits/organization.rb, line 64 def required_keys ["organization", "filings_with_data", "filings_without_data", "data_source", "api_version", "error"].freeze end