Class: Elibri::ONIX::Release_3_0::ExcerptInfo
- Inherits:
-
Object
- Object
- Elibri::ONIX::Release_3_0::ExcerptInfo
- Includes:
- TimestampParser
- Defined in:
- lib/elibri_onix/onix_3_0/excerpt_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.
-
#link ⇒ Object
Returns the value of attribute link.
-
#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) ⇒ ExcerptInfo
constructor
A new instance of ExcerptInfo.
- #inspect_include_fields ⇒ Object
Methods included from TimestampParser
Constructor Details
#initialize(data) ⇒ ExcerptInfo
Returns a new instance of ExcerptInfo.
9 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 |
# File 'lib/elibri_onix/onix_3_0/excerpt_info.rb', line 9 def initialize(data) @to_xml = data.to_s if data.name == "excerpt" @file_type = data.attributes['file_type'].value @file_size = data.attributes['file_size'].value.to_i @md5 = data.attributes['md5'].value @updated_at = (data.attributes['updated_at'].value) @link = data.text @eid = data.attributes['id'].value.to_i elsif data.name == "ResourceVersion" last_updated_node = data.css("ContentDate").find { |date| date.css("ContentDateRole").first.inner_text == Elibri::ONIX::Dict::Release_3_0::ContentDateRole::LAST_UPDATED } if last_updated_node @updated_at = (last_updated_node.css("Date").first.inner_text) end @link = data.css("ResourceLink").first.text @eid = @link.split("/")[4].to_i @file_type = @link.split(".").last + "_excerpt" data.css("ResourceVersionFeature").each do |feature| feature_type = feature.css("ResourceVersionFeatureType").first.inner_text feature_value = feature.css("FeatureValue").first.inner_text if feature_type == Elibri::ONIX::Dict::Release_3_0::ResourceVersionFeatureType::MD5_HASH_VALUE @md5 = feature_value elsif feature_type == Elibri::ONIX::Dict::Release_3_0::ResourceVersionFeatureType::SIZE_IN_BYTES @file_size = feature_value.to_i end end else raise ArgumentError, "Unknow element for ExcerptInfo: #{data.name}" end end |
Instance Attribute Details
#eid ⇒ Object
Returns the value of attribute eid.
7 8 9 |
# File 'lib/elibri_onix/onix_3_0/excerpt_info.rb', line 7 def eid @eid end |
#file_size ⇒ Object
Returns the value of attribute file_size.
7 8 9 |
# File 'lib/elibri_onix/onix_3_0/excerpt_info.rb', line 7 def file_size @file_size end |
#file_type ⇒ Object
Returns the value of attribute file_type.
7 8 9 |
# File 'lib/elibri_onix/onix_3_0/excerpt_info.rb', line 7 def file_type @file_type end |
#link ⇒ Object
Returns the value of attribute link.
7 8 9 |
# File 'lib/elibri_onix/onix_3_0/excerpt_info.rb', line 7 def link @link end |
#md5 ⇒ Object
Returns the value of attribute md5.
7 8 9 |
# File 'lib/elibri_onix/onix_3_0/excerpt_info.rb', line 7 def md5 @md5 end |
#to_xml ⇒ Object
Returns the value of attribute to_xml.
7 8 9 |
# File 'lib/elibri_onix/onix_3_0/excerpt_info.rb', line 7 def to_xml @to_xml end |
#updated_at ⇒ Object
Returns the value of attribute updated_at.
7 8 9 |
# File 'lib/elibri_onix/onix_3_0/excerpt_info.rb', line 7 def updated_at @updated_at end |
Instance Method Details
#inspect_include_fields ⇒ Object
43 44 45 |
# File 'lib/elibri_onix/onix_3_0/excerpt_info.rb', line 43 def inspect_include_fields [:link] end |