A Resource object is valid if
- it has a resource description
Included modules
- Validation
Attributes
Public class methods
new
( attributes = {} )
[show source]
# File lib/rcap/cap_1_1/resource.rb, line 39 def initialize( attributes = {} ) @mime_type = attributes[ :mime_type ] @size = attributes[ :size ] @uri = attributes[ :uri ] @deref_uri = attributes[ :deref_uri ] @digest = attributes[ :digest ] @resource_desc = attributes[ :resource_desc ] end
Public instance methods
deref_uri=
( value )
Sets the deref_uri. The SHA digest and size are also calculated and set.
[show source]
# File lib/rcap/cap_1_1/resource.rb, line 81 def deref_uri=( value ) @deref_uri = value self.digest = Digest::SHA1.hexdigest( @deref_uri ) self.size = @deref_uri.bytesize end
dereference_uri!
()
Retrieves the content at uri and stores it in deref_uri as Base64 encoded text. It will also calculate the digest on the encoded data using SHA1 and set the size.
This uses the open-uri Ruby API to open and read the content.
[show source]
# File lib/rcap/cap_1_1/resource.rb, line 92 def dereference_uri! content = URI.parse( self.uri ).read self.deref_uri = Base64.encode64( content ) end
size_in_kb
()
If size is defined returns the size in kilobytes
[show source]
# File lib/rcap/cap_1_1/resource.rb, line 60 def size_in_kb if self.size self.size.to_f/1024 end end
to_s
()
Returns a string representation of the resource of the form
resource_desc
[show source]
# File lib/rcap/cap_1_1/resource.rb, line 76 def to_s self.resource_desc end