Class: ADPDownloader::Statement

Inherits:
Object
  • Object
show all
Defined in:
lib/adp-downloader/statement/statement.rb

Direct Known Subclasses

PayStatement, TaxStatement

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ Statement

Returns a new instance of Statement.



3
4
5
# File 'lib/adp-downloader/statement/statement.rb', line 3

def initialize(json)
  @data = json
end

Instance Method Details

#_(string) ⇒ Object



50
51
52
# File 'lib/adp-downloader/statement/statement.rb', line 50

def _(string)
  get_info(@data, string.split("."))
end

#file_suffixObject



29
30
31
# File 'lib/adp-downloader/statement/statement.rb', line 29

def file_suffix
  nil
end

#filenameObject



20
21
22
# File 'lib/adp-downloader/statement/statement.rb', line 20

def filename
  [date, id, file_suffix].compact.join("-")
end

#full_path(name) ⇒ Object



24
25
26
27
# File 'lib/adp-downloader/statement/statement.rb', line 24

def full_path(name)
  parts = [Config.employer, year, name].compact
  File.join(*parts)
end

#jsonObject



46
47
48
# File 'lib/adp-downloader/statement/statement.rb', line 46

def json
  full_path("#{filename}.json")
end

#merge(details) ⇒ Object



15
16
17
18
# 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

#pdfObject



42
43
44
# File 'lib/adp-downloader/statement/statement.rb', line 42

def pdf
  full_path("#{filename}.pdf")
end

#pdf_uriObject



33
34
35
36
# 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

#yearObject



38
39
40
# File 'lib/adp-downloader/statement/statement.rb', line 38

def year
  date.split("-").first
end