lib/rcap/base/resource.rb in rcap-2.2.1 vs lib/rcap/base/resource.rb in rcap-2.3.0

- old
+ new

@@ -61,24 +61,24 @@ resource.size = RCAP.xpath_text( resource_xml_element, SIZE_XPATH, resource.xmlns ).to_i resource.digest = RCAP.xpath_text( resource_xml_element, DIGEST_XPATH, resource.xmlns ) end end - # Calculates the SHA-1 hash and size of the contents of {#deref_uri}. + # Calculates the SHA-1 hash and size of the contents of {RCAP::Base::Resource#deref_uri}. # Returns an array containing the size (in bytes) and SHA-1 hash if - # {#deref_uri} is present otherwise returns nil. + # {RCAP::Base::Resource#deref_uri} is present otherwise returns nil. # # @return [nil,Array(Integer,String)] def calculate_hash_and_size if @deref_uri @digest = Digest::SHA1.hexdigest( @deref_uri ) @size = @deref_uri.bytesize [ @size, @digest ] end end - # The decoded contents of {#deref_uri} if present otherwise nil. + # The decoded contents of {RCAP::Base::Resource#deref_uri} if present otherwise nil. # # @return [nil,String] def decoded_deref_uri Base64.decode64( @deref_uri ) if @deref_uri end @@ -113,17 +113,21 @@ URI_YAML = "URI" MIME_TYPE_YAML = "Mime Type" SIZE_YAML = "Size" DIGEST_YAML = "Digest" - # @param [Hash] options - # @return [String] - def to_yaml( options = {} ) + def to_yaml_data RCAP.attribute_values_to_hash( [ RESOURCE_DESC_YAML, @resource_desc ], [ URI_YAML, @uri ], [ MIME_TYPE_YAML, @mime_type ], [ SIZE_YAML, @size ], - [ DIGEST_YAML, @digest ]).to_yaml( options ) + [ DIGEST_YAML, @digest ]) + end + + # @param [Hash] options + # @return [String] + def to_yaml( options = {} ) + self.to_yaml_data.to_yaml( options ) end # @param [Hash] resource_yaml_data # @return [Resource] def self.from_yaml_data( resource_yaml_data )