Class: Sunnyside::InvoiceParse
- Inherits:
-
Object
- Object
- Sunnyside::InvoiceParse
- Defined in:
- lib/sunnyside/ledger/private.rb
Instance Attribute Summary collapse
-
#client_line ⇒ Object
readonly
Returns the value of attribute client_line.
-
#invoice_line ⇒ Object
readonly
Returns the value of attribute invoice_line.
-
#service_lines ⇒ Object
readonly
Returns the value of attribute service_lines.
Instance Method Summary collapse
- #client_number ⇒ Object
-
#initialize(page) ⇒ InvoiceParse
constructor
A new instance of InvoiceParse.
- #invoice ⇒ Object
- #process ⇒ Object
Constructor Details
#initialize(page) ⇒ InvoiceParse
Returns a new instance of InvoiceParse.
18 19 20 21 22 |
# File 'lib/sunnyside/ledger/private.rb', line 18 def initialize(page) @invoice_line = page.select { |line| line =~ /[0-9\/]{8}\s+\d{7}/ }.join @client_line = page.select { |line| line =~ /[0-9]{7}\s+[0-9]{7}/ }.join @service_lines = page.map { |line| ServiceLine.new(line) if line =~ /\sHHA\s|\sPCA\s/ }.compact end |
Instance Attribute Details
#client_line ⇒ Object (readonly)
Returns the value of attribute client_line.
17 18 19 |
# File 'lib/sunnyside/ledger/private.rb', line 17 def client_line @client_line end |
#invoice_line ⇒ Object (readonly)
Returns the value of attribute invoice_line.
17 18 19 |
# File 'lib/sunnyside/ledger/private.rb', line 17 def invoice_line @invoice_line end |
#service_lines ⇒ Object (readonly)
Returns the value of attribute service_lines.
17 18 19 |
# File 'lib/sunnyside/ledger/private.rb', line 17 def service_lines @service_lines end |
Instance Method Details
#client_number ⇒ Object
28 29 30 |
# File 'lib/sunnyside/ledger/private.rb', line 28 def client_number client_line[/[0-9]{7}/] end |
#invoice ⇒ Object
24 25 26 |
# File 'lib/sunnyside/ledger/private.rb', line 24 def invoice invoice_line[/(\d{7})$/, 1].gsub(/^0/, '') end |
#process ⇒ Object
32 33 34 |
# File 'lib/sunnyside/ledger/private.rb', line 32 def process service_lines.each { |line| line.to_db(invoice, client_number) } end |