Class: Sunnyside::ServiceLine
- Inherits:
-
Object
- Object
- Sunnyside::ServiceLine
- Defined in:
- lib/sunnyside/ledger/private.rb
Instance Attribute Summary collapse
-
#line ⇒ Object
readonly
Returns the value of attribute line.
Instance Method Summary collapse
- #amount ⇒ Object
- #code ⇒ Object
-
#initialize(line) ⇒ ServiceLine
constructor
A new instance of ServiceLine.
- #line_split ⇒ Object
- #rate ⇒ Object
- #service_date ⇒ Object
- #to_db(invoice, client_number) ⇒ Object
Constructor Details
#initialize(line) ⇒ ServiceLine
Returns a new instance of ServiceLine.
40 41 42 |
# File 'lib/sunnyside/ledger/private.rb', line 40 def initialize(line) @line = line end |
Instance Attribute Details
#line ⇒ Object (readonly)
Returns the value of attribute line.
38 39 40 |
# File 'lib/sunnyside/ledger/private.rb', line 38 def line @line end |
Instance Method Details
#amount ⇒ Object
64 65 66 |
# File 'lib/sunnyside/ledger/private.rb', line 64 def amount line_split[-1] end |
#code ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/sunnyside/ledger/private.rb', line 52 def code if line =~ / HHA / 'HHA' else 'PCA' end end |
#line_split ⇒ Object
60 61 62 |
# File 'lib/sunnyside/ledger/private.rb', line 60 def line_split line.split end |
#rate ⇒ Object
68 69 70 |
# File 'lib/sunnyside/ledger/private.rb', line 68 def rate line_split[-2] end |
#service_date ⇒ Object
48 49 50 |
# File 'lib/sunnyside/ledger/private.rb', line 48 def service_date line[/[0-9\/]{8}/, 0] end |
#to_db(invoice, client_number) ⇒ Object
44 45 46 |
# File 'lib/sunnyside/ledger/private.rb', line 44 def to_db(invoice, client_number) Visit.insert(invoice_id: invoice, client_id: client_number, dos: Date.strptime(service_date, '%m/%d/%y'), service_code: code, amount: amount) end |