Method: BLS_API::Month#percent_change

Defined in:
lib/bls_api/month.rb

#percent_change(timeframe) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/bls_api/month.rb', line 42

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