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, line 21 def initialize(first, uri = nil, orcid = nil) if first.instance_of?(Hash) name = first[:name] uri = first[:uri] orcid = first[:orcid] else name = first end @structure = { :name => name, :uri => Util.is_absolute_uri?(uri) ? uri.to_s : nil, :orcid => Util.is_absolute_uri?(orcid) ? orcid.to_s : nil } end
Public Instance Methods
name → string
click to toggle source
The name of this agent.
# File lib/ro-bundle/ro/agent.rb, line 41 def name @structure[:name] end
orcid → URI
click to toggle source
An ORCID identifier URI for this agent.
# File lib/ro-bundle/ro/agent.rb, line 58 def orcid @structure[:orcid] 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, line 67 def to_json(*a) Util.clean_json(@structure).to_json(*a) 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, line 50 def uri @structure[:uri] end