lib/rcap/base/resource.rb in rcap-2.7.0 vs lib/rcap/base/resource.rb in rcap-2.7.3
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
module RCAP
module Base
class Resource
include Validation
@@ -21,16 +23,16 @@
SIZE_ELEMENT_NAME = 'size'
URI_ELEMENT_NAME = 'uri'
DIGEST_ELEMENT_NAME = 'digest'
RESOURCE_DESC_ELEMENT_NAME = 'resourceDesc'
- XPATH = "cap:#{ XML_ELEMENT_NAME }"
- MIME_TYPE_XPATH = "cap:#{ MIME_TYPE_ELEMENT_NAME }"
- SIZE_XPATH = "cap:#{ SIZE_ELEMENT_NAME }"
- URI_XPATH = "cap:#{ URI_ELEMENT_NAME }"
- DIGEST_XPATH = "cap:#{ DIGEST_ELEMENT_NAME }"
- RESOURCE_DESC_XPATH = "cap:#{ RESOURCE_DESC_ELEMENT_NAME }"
+ XPATH = "cap:#{XML_ELEMENT_NAME}"
+ MIME_TYPE_XPATH = "cap:#{MIME_TYPE_ELEMENT_NAME}"
+ SIZE_XPATH = "cap:#{SIZE_ELEMENT_NAME}"
+ URI_XPATH = "cap:#{URI_ELEMENT_NAME}"
+ DIGEST_XPATH = "cap:#{DIGEST_ELEMENT_NAME}"
+ RESOURCE_DESC_XPATH = "cap:#{RESOURCE_DESC_ELEMENT_NAME}"
# @param [Hash{Symbol => Object}] attributes
# @option attributes [String] :mime_type
# @option attributes [Numeric] :size Size in bytes
# @option attributes [String] :uri
@@ -84,12 +86,10 @@
end
# If size is defined returns the size in kilobytes
# @return [Float]
def size_in_kb
- if @size
- @size.to_f / 1024
- end
+ @size.to_f / 1024 if @size
end
# @return [String]
def to_xml
to_xml_element.to_s