class ROBundle::Agent
A class to represent an agent in a Research Object. An agent can be, for example, a person or software.
Public Class Methods
new(name, uri = nil, orcid = nil)
click to toggle source
Create a new Agent
with the supplied details. If uri
or orcid
are not absolute URIs then they are set to nil
.
# File lib/ro-bundle/ro/agent.rb 21 def initialize(first, uri = nil, orcid = nil) 22 if first.instance_of?(Hash) 23 name = first[:name] 24 uri = first[:uri] 25 orcid = first[:orcid] 26 else 27 name = first 28 end 29 30 @structure = { 31 :name => name, 32 :uri => Util.is_absolute_uri?(uri) ? uri.to_s : nil, 33 :orcid => Util.is_absolute_uri?(orcid) ? orcid.to_s : nil 34 } 35 end
Public Instance Methods
name → string
click to toggle source
The name of this agent.
# File lib/ro-bundle/ro/agent.rb 41 def name 42 @structure[:name] 43 end
orcid → URI
click to toggle source
An ORCID identifier URI for this agent.
# File lib/ro-bundle/ro/agent.rb 58 def orcid 59 @structure[:orcid] 60 end
to_json(options = nil) → String
click to toggle source
Write this Agent
out as a json string. Takes the same options as JSON#generate.
# File lib/ro-bundle/ro/agent.rb 67 def to_json(*a) 68 JSON.generate(Util.clean_json(@structure),*a) 69 end
uri → URI
click to toggle source
A URI identifying the agent. This should, if it exists, be a WebID.
# File lib/ro-bundle/ro/agent.rb 50 def uri 51 @structure[:uri] 52 end