Module: RBook::Onix
- Defined in:
- lib/rbook/onix.rb,
lib/rbook/onix/message.rb,
lib/rbook/onix/product.rb,
lib/rbook/onix/contributor.rb,
lib/rbook/onix/stream_reader.rb,
lib/rbook/onix/stream_writer.rb,
lib/rbook/onix/supply_detail.rb,
lib/rbook/onix/sales_restriction.rb,
lib/rbook/onix/lists/product_form.rb,
lib/rbook/onix/lists/contributor_role.rb
Overview
Ruby classes for working with ONIX files. Currently only supports a very limited subset of the ONIX specification, but the core attributes are there. More will be added over time.
Usage
Loading from an REXML document
require 'rubygems'
require 'rbook/onix'
file = File.open("./onix_message.xml", "r")
doc = REXML::Document.new(file)
msg = Onix::Message.load_from_xmldoc(doc)
puts msg.from_company
Creation
require 'rubygems'
require 'rbook/onix'
msg = RBook::Onix::Message.new
msg.from_company = 'XYZ Books'
msg.from_name = 'Joe Blogs'
msg. = "A sample ONIX file"
product = RBook::Onix::Product.new
product.product_identifier = "020161622X"
product.title = "Pragmatic Programmer"
product.subtitle = "From Journeyman to Master"
product.form = "BB"
product.description = "A book about programming and stuff"
contributor1 = RBook::Onix::Contributor.new
contributor1.name_inverted = "Hunt, Andrew"
contributor1.role = "A01"
contributor1.sequence = "01"
contributor2 = RBook::Onix::Contributor.new
contributor2.name_inverted = "Thomas, David"
contributor2.role = "A01"
contributor2.sequence = "02"
product.add_contributor(contributor1)
product.add_contributor(contributor2)
supply_detail = RBook::Onix::SupplyDetail.new
supply_detail.supplier_name = "Rainbow Book Agencies"
supply_detail.price = BigDecimal.new(29.95)
supply_detail.availability = "CS"
product.add_supply_detail(supply_detail)
msg.add_product(product)
puts msg.to_s
Defined Under Namespace
Modules: Lists Classes: Contributor, InvalidRubyVersionError, Listener, Message, Product, SalesRestriction, StreamReader, StreamWriter, SupplyDetail