class ROBundle::Aggregate
A class to represent an aggregated resource in a Research Object. It holds standard meta-data for either file or URI resources. An aggregate can only represent a file OR a URI resource, not both at once.
Public Class Methods
new(filename, mediatype = nil)
click to toggle source
new(URI)
Create a new file or URI aggregate.
# File lib/ro-bundle/ro/aggregate.rb, line 23 def initialize(object, second = nil) @structure = {} if object.instance_of?(Hash) init_json(object) else init_file_or_uri(object) if @structure[:file] @structure[:mediatype] = second end end end
Public Instance Methods
file
click to toggle source
The path of this aggregate. It should start with ‘/’.
# File lib/ro-bundle/ro/aggregate.rb, line 41 def file @structure[:file] end
file_entry
click to toggle source
The path of this aggregate in “rubyzip” format, i.e. no leading ‘/’.
# File lib/ro-bundle/ro/aggregate.rb, line 49 def file_entry Util.strip_leading_slash(file) end
mediatype
click to toggle source
For a file aggregate, its IANA media type.
# File lib/ro-bundle/ro/aggregate.rb, line 66 def mediatype @structure[:mediatype] end
to_json(options = nil) → String
click to toggle source
Write this Aggregate out as a json string. Takes the same options as JSON#generate.
# File lib/ro-bundle/ro/aggregate.rb, line 75 def to_json(*a) Util.clean_json(@structure).to_json(*a) end
uri
click to toggle source
The URI of this aggregate. It should be an absolute URI.
# File lib/ro-bundle/ro/aggregate.rb, line 57 def uri @structure[:uri] end