Method: BLS_API::Month#net_change

Defined in:
lib/bls_api/month.rb

#net_change(timeframe) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/bls_api/month.rb', line 28

def net_change(timeframe)
  unless @raw_month.include?("calculations")
    raise BLS_API::NotRetrievedError, "Calculations not retrieved"
  end
  net_changes = @raw_month["calculations"].fetch("net_changes") do
    raise BLS_API::NotRetrievedError, (
      "Net-change calculations not available from BLS")
  end
  net_changes.fetch(timeframe) do
    raise BLS_API::NotRetrievedError, (
      "#{timeframe}-month net changes not available from BLS")
  end
end