Class: PXMyPortal::Payslip
- Inherits:
-
Object
- Object
- PXMyPortal::Payslip
- Defined in:
- lib/pxmyportal/payslip.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#directory ⇒ Object
readonly
Returns the value of attribute directory.
-
#year_month ⇒ Object
readonly
Returns the value of attribute year_month.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #filename ⇒ Object
- #form_data ⇒ Object
-
#initialize(year_month:, description:, key1:, key2:, key3:, directory: PXMyPortal::XDG::DOC_DIR) ⇒ Payslip
constructor
A new instance of Payslip.
- #metadata ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(year_month:, description:, key1:, key2:, key3:, directory: PXMyPortal::XDG::DOC_DIR) ⇒ Payslip
Returns a new instance of Payslip.
21 22 23 24 25 26 27 28 29 |
# File 'lib/pxmyportal/payslip.rb', line 21 def initialize(year_month:, description:, key1:, key2:, key3:, directory: PXMyPortal::XDG::DOC_DIR) @year_month = year_month @description = description @key1 = key1 @key2 = key2 @key3 = key3 @directory = directory end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
19 20 21 |
# File 'lib/pxmyportal/payslip.rb', line 19 def description @description end |
#directory ⇒ Object (readonly)
Returns the value of attribute directory.
19 20 21 |
# File 'lib/pxmyportal/payslip.rb', line 19 def directory @directory end |
#year_month ⇒ Object (readonly)
Returns the value of attribute year_month.
19 20 21 |
# File 'lib/pxmyportal/payslip.rb', line 19 def year_month @year_month end |
Class Method Details
.from_row(row, directory: nil) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/pxmyportal/payslip.rb', line 54 def self.from_row(row, directory: nil) row.xpath("./td") => [year_month, description, ] year_month.xpath(".//text()") => [year_month] description.xpath(".//text()") => [description] .xpath(".//@onclick") => [listener] listener = listener.value keys = /\AOpenPdf\('(?<key1>\d+)','(?<key2>\d+)',(?<key3>\d+)\);\z/ match = listener.match(keys) or raise Error, listener.inspect key1 = match[:key1] key2 = match[:key2] key3 = match[:key3] = {} directory and [:directory] = directory new(year_month: year_month.content, description: description.content, key1:, key2:, key3:, **) end |
Instance Method Details
#==(other) ⇒ Object
44 45 46 47 48 |
# File 'lib/pxmyportal/payslip.rb', line 44 def ==(other) other => Hash @year_month == other[:year_month] \ && @description == other[:description] end |
#filename ⇒ Object
31 32 33 |
# File 'lib/pxmyportal/payslip.rb', line 31 def filename @filename ||= File.join(@directory, "#{@key1}-#{@key2}-#{@key3}.pdf") end |
#form_data ⇒ Object
35 36 37 |
# File 'lib/pxmyportal/payslip.rb', line 35 def form_data { key1: @key1, key2: @key2, key3: @key3 } end |
#metadata ⇒ Object
39 40 41 42 |
# File 'lib/pxmyportal/payslip.rb', line 39 def { year_month: @year_month, description: @description, filename: @filename } end |
#to_s ⇒ Object
50 51 52 |
# File 'lib/pxmyportal/payslip.rb', line 50 def to_s "#<Payslip #{year_month.inspect} #{description.inspect}>" end |