Class: ROBundle::Proxy

Inherits:
ManifestEntry show all
Defined in:
lib/ro-bundle/ro/proxy.rb

Overview

A class to represent an ORE Proxy for an Aggregate as per the specification of the JSON structure of the manifest.

Instance Method Summary collapse

Methods inherited from ManifestEntry

#edited?, #stored

Methods included from Provenance

#add_author, #authored_by, #authored_on, #authored_on=, #created_by, #created_by=, #created_on, #created_on=, #remove_author, #retrieved_by, #retrieved_by=, #retrieved_from, #retrieved_from=, #retrieved_on, #retrieved_on=

Constructor Details

#initialize(object = "", filename = nil) ⇒ Proxy

:call-seq:

new
new(folder)
new(folder, filename)

Create a new ORE Proxy. If folder is not supplied then “/” is assumed.



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ro-bundle/ro/proxy.rb', line 24

def initialize(object = "", filename = nil)
  super()

  if object.instance_of?(Hash)
    @structure = object
    init_provenance_defaults(@structure)
  else
    @structure = {}
    @structure[:uri] = UUID.generate(:urn)
    @structure[:folder] = folder_slashes(object)
    @structure[:filename] = filename
  end
end

Instance Method Details

#filenameObject

:call-seq:

filename

Return the filename field of this Proxy.



50
51
52
# File 'lib/ro-bundle/ro/proxy.rb', line 50

def filename
  @structure[:filename]
end

#folderObject

:call-seq:

folder

Return the folder field of this Proxy.



42
43
44
# File 'lib/ro-bundle/ro/proxy.rb', line 42

def folder
  @structure[:folder]
end

#to_json(*a) ⇒ Object

:call-seq:

to_json(options = nil) -> String

Write this Proxy out as a json string. Takes the same options as JSON#generate.



67
68
69
# File 'lib/ro-bundle/ro/proxy.rb', line 67

def to_json(*a)
  JSON.generate(Util.clean_json(@structure),*a)
end

#uriObject

:call-seq:

uri -> String in the form of a urn:uuid URI.

Return the annotation id of this Annotation.



58
59
60
# File 'lib/ro-bundle/ro/proxy.rb', line 58

def uri
  @structure[:uri]
end