Class: Elibri::ONIX::Model::Product

Inherits:
Object
  • Object
show all
Defined in:
lib/elibri_onix_generator/model/product.rb

Defined Under Namespace

Classes: OnixGenerator

Instance Attribute Summary collapse

Instance Method Summary collapse

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_kindObject

Returns the value of attribute authorship_kind.



14
15
16
# File 'lib/elibri_onix_generator/model/product.rb', line 14

def authorship_kind
  @authorship_kind
end

#collection_nameObject

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_partObject

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

#contributorsObject

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_nameObject

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_urlObject

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

#descriptionObject

Returns the value of attribute description.



14
15
16
# File 'lib/elibri_onix_generator/model/product.rb', line 14

def description
  @description
end

#edition_statementObject

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

#heightObject

Returns the value of attribute height.



14
15
16
# File 'lib/elibri_onix_generator/model/product.rb', line 14

def height
  @height
end

#isbn_valueObject

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_codeObject

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_illustrationsObject

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_pagesObject

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_titleObject

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

#pkwiuObject

Returns the value of attribute pkwiu.



14
15
16
# File 'lib/elibri_onix_generator/model/product.rb', line 14

def pkwiu
  @pkwiu
end

#price_amountObject

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_codeObject

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_dayObject

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_monthObject

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_yearObject

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_nameObject

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_codeObject

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_referenceObject

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_nameObject

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

#subtitleObject

Returns the value of attribute subtitle.



14
15
16
# File 'lib/elibri_onix_generator/model/product.rb', line 14

def subtitle
  @subtitle
end

#thema_codesObject

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

#thicknessObject

Returns the value of attribute thickness.



14
15
16
# File 'lib/elibri_onix_generator/model/product.rb', line 14

def thickness
  @thickness
end

#titleObject

Returns the value of attribute title.



14
15
16
# File 'lib/elibri_onix_generator/model/product.rb', line 14

def title
  @title
end

#title_partObject

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_titleObject

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

#vatObject

Returns the value of attribute vat.



14
15
16
# File 'lib/elibri_onix_generator/model/product.rb', line 14

def vat
  @vat
end

#weightObject

Returns the value of attribute weight.



14
15
16
# File 'lib/elibri_onix_generator/model/product.rb', line 14

def weight
  @weight
end

#widthObject

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

#attachmentsObject



80
81
82
83
84
85
86
87
# File 'lib/elibri_onix_generator/model/product.rb', line 80

def attachments
  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_issnObject



46
47
# File 'lib/elibri_onix_generator/model/product.rb', line 46

def collection_with_issn
end

#cover_typeObject



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

Returns:

  • (Boolean)


26
27
28
# File 'lib/elibri_onix_generator/model/product.rb', line 26

def kind_of_book?
  true
end

#kind_of_measurable?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/elibri_onix_generator/model/product.rb', line 55

def kind_of_measurable?
  width || height
end

#notification_typeObject



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_textsObject



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

Returns:

  • (Boolean)


112
113
114
# File 'lib/elibri_onix_generator/model/product.rb', line 112

def public?
  true
end

#publication_date_with_onix_format_codeObject



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_onixObject



116
117
118
# File 'lib/elibri_onix_generator/model/product.rb', line 116

def publisher_name_for_onix
  publisher_name
end

#series_membership_kindObject



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_membershipsObject



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_textObject



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_partsObject



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_xmlObject



21
22
23
# File 'lib/elibri_onix_generator/model/product.rb', line 21

def to_xml
  OnixGenerator.new(self, {}).to_s
end