class ADPDownloader::Statement
Public Class Methods
new(json)
click to toggle source
# File lib/adp-downloader/statement/statement.rb, line 3 def initialize(json) @data = json end
Public Instance Methods
_(string)
click to toggle source
# File lib/adp-downloader/statement/statement.rb, line 50 def _(string) get_info(@data, string.split(".")) end
file_suffix()
click to toggle source
# File lib/adp-downloader/statement/statement.rb, line 29 def file_suffix nil end
filename()
click to toggle source
# File lib/adp-downloader/statement/statement.rb, line 20 def filename [date, id, file_suffix].compact.join("-") end
full_path(name)
click to toggle source
# File lib/adp-downloader/statement/statement.rb, line 24 def full_path(name) parts = [Config.employer, year, name].compact File.join(*parts) end
json()
click to toggle source
# File lib/adp-downloader/statement/statement.rb, line 46 def json full_path("#{filename}.json") end
merge(details)
click to toggle source
# File lib/adp-downloader/statement/statement.rb, line 15 def merge(details) top_level_attr, contents = details.first { top_level_attr => @data.merge(contents) } end
pdf()
click to toggle source
# File lib/adp-downloader/statement/statement.rb, line 42 def pdf full_path("#{filename}.pdf") end
pdf_uri()
click to toggle source
# File lib/adp-downloader/statement/statement.rb, line 33 def pdf_uri path = _("statementImageUri.href") path.gsub(%r{^/l2}, "") # remove first characters, since it's incorrect o.O end
year()
click to toggle source
# File lib/adp-downloader/statement/statement.rb, line 38 def year date.split("-").first end
Private Instance Methods
get_info(data, attributes)
click to toggle source
# File lib/adp-downloader/statement/statement.rb, line 55 def get_info(data, attributes) attr = attributes.first info = data[attr] if attributes.size == 1 info else next_data = info.nil? ? {} : info get_info(next_data, attributes.drop(1)) end end