Class: ONIX::ProductPart

Inherits:
SubsetDSL show all
Includes:
EanMethods, ProprietaryIdMethods
Defined in:
lib/onix/descriptive_detail.rb

Overview

product part use full Product to provide file protection and file size

Instance Method Summary collapse

Methods included from ProprietaryIdMethods

#proprietary_ids

Methods included from EanMethods

#ean

Methods inherited from SubsetDSL

_ancestor_registered_scopes, _ancestors_registered_elements, ancestor_registered_scopes, ancestors_registered_elements, element, elements, get_class, #initialize, #parse, ref_to_short, registered_elements, registered_scopes, scope, short_to_ref, #unsupported

Methods inherited from Subset

parse, #parse, tag_match, #tag_match, #unsupported

Constructor Details

This class inherits a constructor from ONIX::SubsetDSL

Instance Method Details

#content_typesObject



151
152
153
# File 'lib/onix/descriptive_detail.rb', line 151

def content_types
  @product_content_types
end

#file_descriptionObject

:category: High level part file description string



196
197
198
# File 'lib/onix/descriptive_detail.rb', line 196

def file_description
  @product_form_description
end

#file_formatObject

:category: High level digital file format string (Epub,Pdf,AmazonKindle)



175
176
177
# File 'lib/onix/descriptive_detail.rb', line 175

def file_format
  self.file_formats.first.human if self.file_formats.first
end

#file_formatsObject



185
186
187
# File 'lib/onix/descriptive_detail.rb', line 185

def file_formats
  @product_form_details.select { |fd| fd.code =~ /^E1.*/ }
end

#file_mimetypeObject



179
180
181
182
183
# File 'lib/onix/descriptive_detail.rb', line 179

def file_mimetype
  if self.file_formats.first
    self.file_formats.first.mimetype
  end
end

#filesizeObject

:category: High level digital file filesize in bytes



240
241
242
243
244
245
246
# File 'lib/onix/descriptive_detail.rb', line 240

def filesize
  if product
    product.filesize
  else
    nil
  end
end

#formObject



143
144
145
# File 'lib/onix/descriptive_detail.rb', line 143

def form
  @product_form
end

#form_detailsObject



147
148
149
# File 'lib/onix/descriptive_detail.rb', line 147

def form_details
  @product_form_details
end

#identifiersObject

shortcuts



139
140
141
# File 'lib/onix/descriptive_detail.rb', line 139

def identifiers
  @product_identifiers
end

#part_ofObject

this ProductPart is part of Product



165
166
167
# File 'lib/onix/descriptive_detail.rb', line 165

def part_of
  @part_of
end

#part_of=(v) ⇒ Object



169
170
171
# File 'lib/onix/descriptive_detail.rb', line 169

def part_of=v
  @part_of=v
end

#productObject

full Product if referenced in ONIXMessage



156
157
158
# File 'lib/onix/descriptive_detail.rb', line 156

def product
  @product
end

#product=(v) ⇒ Object



160
161
162
# File 'lib/onix/descriptive_detail.rb', line 160

def product=v
  @product=v
end

#protection_typeObject

:category: High level Protection type string (None, Watermarking, DRM, AdobeDRM)



212
213
214
215
216
217
218
219
220
221
222
# File 'lib/onix/descriptive_detail.rb', line 212

def protection_type
  if product
    product.protection_type
  else
    if part_of
      part_of.protection_type
    else
      nil
    end
  end
end

#protectionsObject

:category: High level List of protections type string (None, Watermarking, DRM, AdobeDRM)



226
227
228
229
230
231
232
233
234
235
236
# File 'lib/onix/descriptive_detail.rb', line 226

def protections
  if product
    product.protections
  else
    if part_of
      part_of.protections
    else
      nil
    end
  end
end

#raw_file_descriptionObject

:category: High level raw part file description string without HTML



202
203
204
205
206
207
208
# File 'lib/onix/descriptive_detail.rb', line 202

def raw_file_description
  if @product_form_description
    Helper.strip_html(@product_form_description).gsub(/\s+/, " ").strip
  else
    nil
  end
end

#reflowable?Boolean

Returns:

  • (Boolean)


189
190
191
192
# File 'lib/onix/descriptive_detail.rb', line 189

def reflowable?
  return true if @product_form_details.select { |fd| fd.code == "E200" }.length > 0
  return false if @product_form_details.select { |fd| fd.code == "E201" }.length > 0
end