Class: Elibri::ONIX::Release_3_0::FileInfo
- Inherits:
-
Object
- Object
- Elibri::ONIX::Release_3_0::FileInfo
- Includes:
- TimestampParser
- Defined in:
- lib/elibri_onix/onix_3_0/file_info.rb
Instance Attribute Summary collapse
-
#eid ⇒ Object
Returns the value of attribute eid.
-
#file_size ⇒ Object
Returns the value of attribute file_size.
-
#file_type ⇒ Object
Returns the value of attribute file_type.
-
#md5 ⇒ Object
Returns the value of attribute md5.
-
#to_xml ⇒ Object
Returns the value of attribute to_xml.
-
#updated_at ⇒ Object
Returns the value of attribute updated_at.
Instance Method Summary collapse
-
#initialize(data) ⇒ FileInfo
constructor
A new instance of FileInfo.
- #inspect_include_fields ⇒ Object
Methods included from TimestampParser
Constructor Details
#initialize(data) ⇒ FileInfo
Returns a new instance of FileInfo.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/elibri_onix/onix_3_0/file_info.rb', line 10 def initialize(data) @to_xml = data.to_s data.css("ResourceFileDate").each do |date| if date.css("ResourceFileDateRole").first.inner_text == Elibri::ONIX::Dict::Release_3_0::ContentDateRole::LAST_UPDATED @updated_at = (date.css("Date").first.inner_text) end end data.css("ResourceFileFeature").each do |feat| ftype = feat.css("ResourceFileFeatureType").first.inner_text fvalue = feat.css("ResourceFileFeatureValue").first.inner_text if ftype == Elibri::ONIX::Dict::Release_3_0::ResourceFileFeatureType::EXACT_FILE_SIZE @file_size = fvalue.to_i elsif ftype == Elibri::ONIX::Dict::Release_3_0::ResourceFileFeatureType::MD5 @md5 = fvalue end end fname = data.css("ResourceFileLink").first&.inner_text if fname if File.extname(fname) == ".zip" @file_type = "mp3_in_zip" else @file_type = File.extname(fname)[1..-1] end end data.css("ResourceIdentifier").each do |ident| if ident.css("ResourceIDType").first&.inner_text == Elibri::ONIX::Dict::Release_3_0::ResourceIDType::PROPRIETARY @eid = ident.css("IDValue").first&.inner_text&.to_i end end end |
Instance Attribute Details
#eid ⇒ Object
Returns the value of attribute eid.
8 9 10 |
# File 'lib/elibri_onix/onix_3_0/file_info.rb', line 8 def eid @eid end |
#file_size ⇒ Object
Returns the value of attribute file_size.
8 9 10 |
# File 'lib/elibri_onix/onix_3_0/file_info.rb', line 8 def file_size @file_size end |
#file_type ⇒ Object
Returns the value of attribute file_type.
8 9 10 |
# File 'lib/elibri_onix/onix_3_0/file_info.rb', line 8 def file_type @file_type end |
#md5 ⇒ Object
Returns the value of attribute md5.
8 9 10 |
# File 'lib/elibri_onix/onix_3_0/file_info.rb', line 8 def md5 @md5 end |
#to_xml ⇒ Object
Returns the value of attribute to_xml.
8 9 10 |
# File 'lib/elibri_onix/onix_3_0/file_info.rb', line 8 def to_xml @to_xml end |
#updated_at ⇒ Object
Returns the value of attribute updated_at.
8 9 10 |
# File 'lib/elibri_onix/onix_3_0/file_info.rb', line 8 def updated_at @updated_at end |
Instance Method Details
#inspect_include_fields ⇒ Object
46 47 48 |
# File 'lib/elibri_onix/onix_3_0/file_info.rb', line 46 def inspect_include_fields [:file_type] end |