Class: Elibri::ONIX::Model::Product
- Inherits:
-
Object
- Object
- Elibri::ONIX::Model::Product
- Defined in:
- lib/elibri_onix_generator/model/product.rb
Defined Under Namespace
Classes: OnixGenerator
Instance Attribute Summary collapse
-
#authorship_kind ⇒ Object
Returns the value of attribute authorship_kind.
-
#collection_name ⇒ Object
Returns the value of attribute collection_name.
-
#collection_part ⇒ Object
Returns the value of attribute collection_part.
-
#contributors ⇒ Object
Returns the value of attribute contributors.
-
#cover_type_name ⇒ Object
Returns the value of attribute cover_type_name.
-
#cover_url ⇒ Object
Returns the value of attribute cover_url.
-
#description ⇒ Object
Returns the value of attribute description.
-
#edition_statement ⇒ Object
Returns the value of attribute edition_statement.
-
#height ⇒ Object
Returns the value of attribute height.
-
#isbn_value ⇒ Object
Returns the value of attribute isbn_value.
-
#notification_type_onix_code ⇒ Object
Returns the value of attribute notification_type_onix_code.
-
#number_of_illustrations ⇒ Object
Returns the value of attribute number_of_illustrations.
-
#number_of_pages ⇒ Object
Returns the value of attribute number_of_pages.
-
#original_title ⇒ Object
Returns the value of attribute original_title.
-
#pkwiu ⇒ Object
Returns the value of attribute pkwiu.
-
#price_amount ⇒ Object
Returns the value of attribute price_amount.
-
#product_form_onix_code ⇒ Object
Returns the value of attribute product_form_onix_code.
-
#publication_day ⇒ Object
Returns the value of attribute publication_day.
-
#publication_month ⇒ Object
Returns the value of attribute publication_month.
-
#publication_year ⇒ Object
Returns the value of attribute publication_year.
-
#publisher_name ⇒ Object
Returns the value of attribute publisher_name.
-
#publishing_status_onix_code ⇒ Object
Returns the value of attribute publishing_status_onix_code.
-
#record_reference ⇒ Object
Returns the value of attribute record_reference.
-
#series_name ⇒ Object
Returns the value of attribute series_name.
-
#subtitle ⇒ Object
Returns the value of attribute subtitle.
-
#thema_codes ⇒ Object
Returns the value of attribute thema_codes.
-
#thickness ⇒ Object
Returns the value of attribute thickness.
-
#title ⇒ Object
Returns the value of attribute title.
-
#title_part ⇒ Object
Returns the value of attribute title_part.
-
#trade_title ⇒ Object
Returns the value of attribute trade_title.
-
#vat ⇒ Object
Returns the value of attribute vat.
-
#weight ⇒ Object
Returns the value of attribute weight.
-
#width ⇒ Object
Returns the value of attribute width.
Instance Method Summary collapse
- #attachments ⇒ Object
- #collection_with_issn ⇒ Object
- #cover_type ⇒ Object
-
#initialize(attributes = {}) ⇒ Product
constructor
A new instance of Product.
- #kind_of_book? ⇒ Boolean
- #kind_of_measurable? ⇒ Boolean
- #notification_type ⇒ Object
- #other_texts ⇒ Object
- #public? ⇒ Boolean
- #publication_date_with_onix_format_code ⇒ Object
- #publisher_name_for_onix ⇒ Object
- #series_membership_kind ⇒ Object
- #series_memberships ⇒ Object
- #thema_codes_for_onix_with_heading_text ⇒ Object
- #title_parts ⇒ Object
- #to_xml ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Product
Returns a new instance of Product.
124 125 126 127 128 |
# File 'lib/elibri_onix_generator/model/product.rb', line 124 def initialize(attributes = {}) attributes.each do |key, value| self.send("#{key}=", value) end end |
Instance Attribute Details
#authorship_kind ⇒ Object
Returns the value of attribute authorship_kind.
14 15 16 |
# File 'lib/elibri_onix_generator/model/product.rb', line 14 def end |
#collection_name ⇒ Object
Returns the value of attribute collection_name.
14 15 16 |
# File 'lib/elibri_onix_generator/model/product.rb', line 14 def collection_name @collection_name end |
#collection_part ⇒ Object
Returns the value of attribute collection_part.
14 15 16 |
# File 'lib/elibri_onix_generator/model/product.rb', line 14 def collection_part @collection_part end |
#contributors ⇒ Object
Returns the value of attribute contributors.
14 15 16 |
# File 'lib/elibri_onix_generator/model/product.rb', line 14 def contributors @contributors end |
#cover_type_name ⇒ Object
Returns the value of attribute cover_type_name.
14 15 16 |
# File 'lib/elibri_onix_generator/model/product.rb', line 14 def cover_type_name @cover_type_name end |
#cover_url ⇒ Object
Returns the value of attribute cover_url.
14 15 16 |
# File 'lib/elibri_onix_generator/model/product.rb', line 14 def cover_url @cover_url end |
#description ⇒ Object
Returns the value of attribute description.
14 15 16 |
# File 'lib/elibri_onix_generator/model/product.rb', line 14 def description @description end |
#edition_statement ⇒ Object
Returns the value of attribute edition_statement.
14 15 16 |
# File 'lib/elibri_onix_generator/model/product.rb', line 14 def edition_statement @edition_statement end |
#height ⇒ Object
Returns the value of attribute height.
14 15 16 |
# File 'lib/elibri_onix_generator/model/product.rb', line 14 def height @height end |
#isbn_value ⇒ Object
Returns the value of attribute isbn_value.
14 15 16 |
# File 'lib/elibri_onix_generator/model/product.rb', line 14 def isbn_value @isbn_value end |
#notification_type_onix_code ⇒ Object
Returns the value of attribute notification_type_onix_code.
14 15 16 |
# File 'lib/elibri_onix_generator/model/product.rb', line 14 def notification_type_onix_code @notification_type_onix_code end |
#number_of_illustrations ⇒ Object
Returns the value of attribute number_of_illustrations.
14 15 16 |
# File 'lib/elibri_onix_generator/model/product.rb', line 14 def number_of_illustrations @number_of_illustrations end |
#number_of_pages ⇒ Object
Returns the value of attribute number_of_pages.
14 15 16 |
# File 'lib/elibri_onix_generator/model/product.rb', line 14 def number_of_pages @number_of_pages end |
#original_title ⇒ Object
Returns the value of attribute original_title.
14 15 16 |
# File 'lib/elibri_onix_generator/model/product.rb', line 14 def original_title @original_title end |
#pkwiu ⇒ Object
Returns the value of attribute pkwiu.
14 15 16 |
# File 'lib/elibri_onix_generator/model/product.rb', line 14 def pkwiu @pkwiu end |
#price_amount ⇒ Object
Returns the value of attribute price_amount.
14 15 16 |
# File 'lib/elibri_onix_generator/model/product.rb', line 14 def price_amount @price_amount end |
#product_form_onix_code ⇒ Object
Returns the value of attribute product_form_onix_code.
14 15 16 |
# File 'lib/elibri_onix_generator/model/product.rb', line 14 def product_form_onix_code @product_form_onix_code end |
#publication_day ⇒ Object
Returns the value of attribute publication_day.
14 15 16 |
# File 'lib/elibri_onix_generator/model/product.rb', line 14 def publication_day @publication_day end |
#publication_month ⇒ Object
Returns the value of attribute publication_month.
14 15 16 |
# File 'lib/elibri_onix_generator/model/product.rb', line 14 def publication_month @publication_month end |
#publication_year ⇒ Object
Returns the value of attribute publication_year.
14 15 16 |
# File 'lib/elibri_onix_generator/model/product.rb', line 14 def publication_year @publication_year end |
#publisher_name ⇒ Object
Returns the value of attribute publisher_name.
14 15 16 |
# File 'lib/elibri_onix_generator/model/product.rb', line 14 def publisher_name @publisher_name end |
#publishing_status_onix_code ⇒ Object
Returns the value of attribute publishing_status_onix_code.
14 15 16 |
# File 'lib/elibri_onix_generator/model/product.rb', line 14 def publishing_status_onix_code @publishing_status_onix_code end |
#record_reference ⇒ Object
Returns the value of attribute record_reference.
14 15 16 |
# File 'lib/elibri_onix_generator/model/product.rb', line 14 def record_reference @record_reference end |
#series_name ⇒ Object
Returns the value of attribute series_name.
14 15 16 |
# File 'lib/elibri_onix_generator/model/product.rb', line 14 def series_name @series_name end |
#subtitle ⇒ Object
Returns the value of attribute subtitle.
14 15 16 |
# File 'lib/elibri_onix_generator/model/product.rb', line 14 def subtitle @subtitle end |
#thema_codes ⇒ Object
Returns the value of attribute thema_codes.
14 15 16 |
# File 'lib/elibri_onix_generator/model/product.rb', line 14 def thema_codes @thema_codes end |
#thickness ⇒ Object
Returns the value of attribute thickness.
14 15 16 |
# File 'lib/elibri_onix_generator/model/product.rb', line 14 def thickness @thickness end |
#title ⇒ Object
Returns the value of attribute title.
14 15 16 |
# File 'lib/elibri_onix_generator/model/product.rb', line 14 def title @title end |
#title_part ⇒ Object
Returns the value of attribute title_part.
14 15 16 |
# File 'lib/elibri_onix_generator/model/product.rb', line 14 def title_part @title_part end |
#trade_title ⇒ Object
Returns the value of attribute trade_title.
14 15 16 |
# File 'lib/elibri_onix_generator/model/product.rb', line 14 def trade_title @trade_title end |
#vat ⇒ Object
Returns the value of attribute vat.
14 15 16 |
# File 'lib/elibri_onix_generator/model/product.rb', line 14 def vat @vat end |
#weight ⇒ Object
Returns the value of attribute weight.
14 15 16 |
# File 'lib/elibri_onix_generator/model/product.rb', line 14 def weight @weight end |
#width ⇒ Object
Returns the value of attribute width.
14 15 16 |
# File 'lib/elibri_onix_generator/model/product.rb', line 14 def width @width end |
Instance Method Details
#attachments ⇒ Object
80 81 82 83 84 85 86 87 |
# File 'lib/elibri_onix_generator/model/product.rb', line 80 def if cover_url [OpenStruct.new({"onix_resource_mode" => "03", "attachment_type_code" => "01", "url_for_onix" => cover_url, "file" => OpenStruct.new({ "url" => cover_url })})] else [] end end |
#collection_with_issn ⇒ Object
46 47 |
# File 'lib/elibri_onix_generator/model/product.rb', line 46 def collection_with_issn end |
#cover_type ⇒ Object
49 50 51 52 53 |
# File 'lib/elibri_onix_generator/model/product.rb', line 49 def cover_type if cover_type_name && cover_type_name.size > 0 OpenStruct.new(name: cover_type_name) end end |
#kind_of_book? ⇒ Boolean
26 27 28 |
# File 'lib/elibri_onix_generator/model/product.rb', line 26 def kind_of_book? true end |
#kind_of_measurable? ⇒ Boolean
55 56 57 |
# File 'lib/elibri_onix_generator/model/product.rb', line 55 def kind_of_measurable? width || height end |
#notification_type ⇒ Object
90 91 92 |
# File 'lib/elibri_onix_generator/model/product.rb', line 90 def notification_type OpenStruct.new({"onix_code" => notification_type_onix_code}) if notification_type_onix_code end |
#other_texts ⇒ Object
70 71 72 73 74 75 76 77 78 |
# File 'lib/elibri_onix_generator/model/product.rb', line 70 def other_texts if self.description && self.description.size > 0 [OpenStruct.new({ :text => description, :type_onix_code => "03", :exportable? => true})] else [] end end |
#public? ⇒ Boolean
112 113 114 |
# File 'lib/elibri_onix_generator/model/product.rb', line 112 def public? true end |
#publication_date_with_onix_format_code ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/elibri_onix_generator/model/product.rb', line 94 def publication_date_with_onix_format_code publication_year_str = self.publication_year ? "%04d"% self.publication_year : nil publication_month_str = self.publication_month ? "%02d"% self.publication_month : nil publication_day_str = self.publication_day ? "%02d"% self.publication_day : nil publication_date = [publication_year_str, publication_month_str, publication_day_str].compact.join('') if self.publication_year && self.publication_month && self.publication_day [publication_year_str + publication_month_str + publication_day_str, Elibri::ONIX::Dict::Release_3_0::DateFormat::YYYYMMDD] elsif self.publication_year && self.publication_month [publication_year_str + publication_month_str, Elibri::ONIX::Dict::Release_3_0::DateFormat::YYYYMM] elsif self.publication_year [publication_year_str, Elibri::ONIX::Dict::Release_3_0::DateFormat::YYYY] else [nil, nil] end end |
#publisher_name_for_onix ⇒ Object
116 117 118 |
# File 'lib/elibri_onix_generator/model/product.rb', line 116 def publisher_name_for_onix publisher_name end |
#series_membership_kind ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/elibri_onix_generator/model/product.rb', line 30 def series_membership_kind if series_name && series_name.size > 0 "user_given" else "no_series" end end |
#series_memberships ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/elibri_onix_generator/model/product.rb', line 38 def series_memberships if series_name && series_name.size > 0 [OpenStruct.new(series_name: series_name)] else [] end end |
#thema_codes_for_onix_with_heading_text ⇒ Object
120 121 122 |
# File 'lib/elibri_onix_generator/model/product.rb', line 120 def thema_codes_for_onix_with_heading_text thema_codes || [] end |
#title_parts ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/elibri_onix_generator/model/product.rb', line 60 def title_parts res = [] product_code = Elibri::ONIX::Dict::Release_3_0::TitleElementLevel::PRODUCT #01 collection_code = Elibri::ONIX::Dict::Release_3_0::TitleElementLevel::COLLECTION #02 res << OpenStruct.new(:level => collection_code, :title => collection_name, :part => self.collection_part) if collection_name && collection_name.size > 0 res << OpenStruct.new(:level => product_code, :title => self.title, :subtitle => self.subtitle, :part => self.title_part) if self.title && self.title.size > 0 return res end |
#to_xml ⇒ Object
21 22 23 |
# File 'lib/elibri_onix_generator/model/product.rb', line 21 def to_xml OnixGenerator.new(self, {}).to_s end |