Class: Datanorm::Lines::V5::Product

Inherits:
Base
  • Object
show all
Defined in:
lib/datanorm/lines/v5/product.rb

Overview

Ruby wrapper for one A line of a Datanorm file.

Instance Attribute Summary

Attributes inherited from Base

#columns, #source_line_number

Instance Method Summary collapse

Methods inherited from Base

#encode, inherited, #initialize, #record_kind, #to_json

Constructor Details

This class inherits a constructor from Datanorm::Lines::Base

Instance Method Details

#as_jsonObject



36
37
38
# File 'lib/datanorm/lines/v5/product.rb', line 36

def as_json
  { id:, text_id:, cents:, title:, quantity_unit:, quantity: }
end

#centsObject



20
21
22
# File 'lib/datanorm/lines/v5/product.rb', line 20

def cents
  columns[8].to_i
end

#idObject



12
13
14
# File 'lib/datanorm/lines/v5/product.rb', line 12

def id
  columns[2]
end

#quantityObject



32
33
34
# File 'lib/datanorm/lines/v5/product.rb', line 32

def quantity
  columns[6].to_i.nonzero?
end

#quantity_unitObject



28
29
30
# File 'lib/datanorm/lines/v5/product.rb', line 28

def quantity_unit
  columns[5]
end

#text_idObject



16
17
18
# File 'lib/datanorm/lines/v5/product.rb', line 16

def text_id
  columns[23]
end

#titleObject



24
25
26
# File 'lib/datanorm/lines/v5/product.rb', line 24

def title
  columns[3..4].join(' ').strip
end

#to_sObject



8
9
10
# File 'lib/datanorm/lines/v5/product.rb', line 8

def to_s
  "[#{id}] Product-5 #{item_title} - EUR #{price}"
end