Class: PubliSci::Prov::Agent
- Inherits:
-
Object
- Object
- PubliSci::Prov::Agent
show all
- Includes:
- Element
- Defined in:
- lib/bio-publisci/metadata/prov/agent.rb
Instance Method Summary
collapse
Methods included from Element
#__label, #__label=, #subject, #subject=
#add_custom, #custom, #has
Methods included from Vocabulary
#vocabulary
Instance Method Details
#name(name = nil) ⇒ Object
18
19
20
21
22
23
24
|
# File 'lib/bio-publisci/metadata/prov/agent.rb', line 18
def name(name=nil)
if name
@name = name
else
@name
end
end
|
#name=(name) ⇒ Object
26
27
28
|
# File 'lib/bio-publisci/metadata/prov/agent.rb', line 26
def name=(name)
@name = name
end
|
#on_behalf_of(agent = nil) ⇒ Object
Also known as:
worked_for
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/bio-publisci/metadata/prov/agent.rb', line 44
def on_behalf_of(agent=nil)
if agent
if agent.is_a? Symbol
raise "UnknownAgent: #{agent}" unless Prov.agents.has_key?(agent)
agent = Prov.agents[agent]
end
@on_behalf_of = agent
else
@on_behalf_of
end
end
|
#organization(organization = nil) ⇒ Object
30
31
32
33
34
35
36
37
38
|
# File 'lib/bio-publisci/metadata/prov/agent.rb', line 30
def organization(organization=nil)
if organization
@organization = organization
elsif @organization.is_a? Symbol
@organization = Prov.agents[@organization]
else
@organization
end
end
|
#organization=(organization) ⇒ Object
40
41
42
|
# File 'lib/bio-publisci/metadata/prov/agent.rb', line 40
def organization=(organization)
@organization = organization
end
|
#to_n3 ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/bio-publisci/metadata/prov/agent.rb', line 57
def to_n3
str = "<#{subject}> a prov:Agent"
if type
case type.to_sym
when :software
str << ", prov:SoftwareAgent ;\n"
when :person
str << ", prov:Person ;\n"
when :organization
str << ", prov:Organization ;\n"
end
else
str << " ;\n"
end
if name
if type && type.to_sym == :person
str << "\tfoaf:givenName \"#{name}\" ;\n"
else
str << "\tfoaf:name \"#{name}\" ;\n"
end
end
if on_behalf_of
str << "\tprov:actedOnBehalfOf <#{on_behalf_of}> ;\n"
end
add_custom(str)
str << "\trdfs:label \"#{__label}\" .\n\n"
end
|
#to_s ⇒ Object
89
90
91
|
# File 'lib/bio-publisci/metadata/prov/agent.rb', line 89
def to_s
subject
end
|
#type(t = nil) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/bio-publisci/metadata/prov/agent.rb', line 6
def type(t=nil)
if t
@type = t.to_sym
else
@type
end
end
|
#type=(t) ⇒ Object
14
15
16
|
# File 'lib/bio-publisci/metadata/prov/agent.rb', line 14
def type=(t)
@type = t.to_sym
end
|