Class: RBook::Bisac::POLineItem
- Inherits:
-
Object
- Object
- RBook::Bisac::POLineItem
- Defined in:
- lib/rbook/bisac/po_line_item.rb
Overview
represents a single line on the purchase order. Has attributes like price, qty and description
Instance Attribute Summary collapse
-
#author ⇒ Object
Returns the value of attribute author.
-
#catalogue_code ⇒ Object
Returns the value of attribute catalogue_code.
-
#isbn ⇒ Object
Returns the value of attribute isbn.
-
#line_item_number ⇒ Object
Returns the value of attribute line_item_number.
-
#po_number ⇒ Object
Returns the value of attribute po_number.
-
#price ⇒ Object
Returns the value of attribute price.
-
#qty ⇒ Object
Returns the value of attribute qty.
-
#sequence_number ⇒ Object
Returns the value of attribute sequence_number.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
-
.load_from_string(data) ⇒ Object
returns a new RBook::Bisac::POLineItem object using the data passed in as a string refer to the bisac spec for the expected format of the string.
Instance Attribute Details
#author ⇒ Object
Returns the value of attribute author.
13 14 15 |
# File 'lib/rbook/bisac/po_line_item.rb', line 13 def @author end |
#catalogue_code ⇒ Object
Returns the value of attribute catalogue_code.
12 13 14 |
# File 'lib/rbook/bisac/po_line_item.rb', line 12 def catalogue_code @catalogue_code end |
#isbn ⇒ Object
Returns the value of attribute isbn.
12 13 14 |
# File 'lib/rbook/bisac/po_line_item.rb', line 12 def isbn @isbn end |
#line_item_number ⇒ Object
Returns the value of attribute line_item_number.
11 12 13 |
# File 'lib/rbook/bisac/po_line_item.rb', line 11 def line_item_number @line_item_number end |
#po_number ⇒ Object
Returns the value of attribute po_number.
11 12 13 |
# File 'lib/rbook/bisac/po_line_item.rb', line 11 def po_number @po_number end |
#price ⇒ Object
Returns the value of attribute price.
12 13 14 |
# File 'lib/rbook/bisac/po_line_item.rb', line 12 def price @price end |
#qty ⇒ Object
Returns the value of attribute qty.
12 13 14 |
# File 'lib/rbook/bisac/po_line_item.rb', line 12 def qty @qty end |
#sequence_number ⇒ Object
Returns the value of attribute sequence_number.
11 12 13 |
# File 'lib/rbook/bisac/po_line_item.rb', line 11 def sequence_number @sequence_number end |
#title ⇒ Object
Returns the value of attribute title.
13 14 15 |
# File 'lib/rbook/bisac/po_line_item.rb', line 13 def title @title end |
Class Method Details
.load_from_string(data) ⇒ Object
returns a new RBook::Bisac::POLineItem object using the data passed in as a string refer to the bisac spec for the expected format of the string
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rbook/bisac/po_line_item.rb', line 17 def self.load_from_string(data) raise RBook::InvalidArgumentError, 'data must be a string' unless data.kind_of? String data.strip! item = self.new item.sequence_number = data[2,5].to_i item.po_number = data[7,13].strip item.line_item_number = data[21,10].strip # prefer the 13 digit ISBN if it exists (it's a non-standard, Pacstream extension) # fallback to the ISBN10 item.isbn = data[80,13] item.isbn ||= data[31,10] item.isbn.strip! item.qty = data[41,5].to_i item.catalogue_code = data[46,1].strip item.price = BigDecimal.new(data[47,6]) return item end |