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.
-
#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:) ⇒ Payslip
constructor
A new instance of Payslip.
- #metadata ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(year_month:, description:, key1:, key2:, key3:) ⇒ Payslip
Returns a new instance of Payslip.
21 22 23 24 25 26 27 |
# File 'lib/pxmyportal/payslip.rb', line 21 def initialize(year_month:, description:, key1:, key2:, key3:) @year_month = year_month @description = description @key1 = key1 @key2 = key2 @key3 = key3 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 |
#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) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/pxmyportal/payslip.rb', line 52 def self.from_row(row) 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] new(year_month: year_month.content, description: description.content, key1:, key2:, key3:) end |
Instance Method Details
#==(other) ⇒ Object
42 43 44 45 46 |
# File 'lib/pxmyportal/payslip.rb', line 42 def ==(other) other => Hash @year_month == other[:year_month] \ && @description == other[:description] end |
#filename ⇒ Object
29 30 31 |
# File 'lib/pxmyportal/payslip.rb', line 29 def filename @filename ||= "#{@key1}-#{@key2}-#{@key3}.pdf" end |
#form_data ⇒ Object
33 34 35 |
# File 'lib/pxmyportal/payslip.rb', line 33 def form_data { key1: @key1, key2: @key2, key3: @key3 } end |
#metadata ⇒ Object
37 38 39 40 |
# File 'lib/pxmyportal/payslip.rb', line 37 def { year_month: @year_month, description: @description, filename: @filename } end |
#to_s ⇒ Object
48 49 50 |
# File 'lib/pxmyportal/payslip.rb', line 48 def to_s "#<Payslip #{year_month.inspect} #{description.inspect}>" end |