Class: PubliSci::Prov::Agent

Inherits:
Object
  • Object
show all
Includes:
Element
Defined in:
lib/publisci/metadata/prov/agent.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Element

#__label, #__label=, #subject, #subject=, #subject_id

Methods included from CustomPredicate

#add_custom, #custom, #has

Methods included from Vocabulary

#vocabulary

Instance Attribute Details

#behalf_ofObject

Returns the value of attribute behalf_of.



6
7
8
# File 'lib/publisci/metadata/prov/agent.rb', line 6

def behalf_of
  @behalf_of
end

#organization(organization = nil) ⇒ Object

Returns the value of attribute organization.



5
6
7
# File 'lib/publisci/metadata/prov/agent.rb', line 5

def organization
  @organization
end

Instance Method Details

#name(name = nil) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/publisci/metadata/prov/agent.rb', line 20

def name(name=nil)
  if name
    @name = name
  else
    @name
  end
end

#name=(name) ⇒ Object



28
29
30
# File 'lib/publisci/metadata/prov/agent.rb', line 28

def name=(name)
  @name = name
end

#on_behalf_of(other_agent = nil) ⇒ Object Also known as: worked_for

def organization=(organization)

@organization = organization

end



48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/publisci/metadata/prov/agent.rb', line 48

def on_behalf_of(other_agent=nil)
  basic_keyword(:behalf_of,:agents,other_agent)
  # if other_agent
  #   @behalf_of = other_agent
  # elsif @on_behalf_of.is_a? Symbol
  #   raise "UnknownAgent: #{@on_behalf_of}" unless Prov.agents.has_key?(@on_behalf_of)
  #   @behalf_of = Prov.agents[@on_behalf_of]
  # else
  #   @behalf_of
  # end

  # @behalf_of
end

#to_n3Object



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
88
89
90
91
92
93
# File 'lib/publisci/metadata/prov/agent.rb', line 63

def to_n3
  str = "<#{subject}> a"
  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 << " prov:Agent ;\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_sObject



95
96
97
# File 'lib/publisci/metadata/prov/agent.rb', line 95

def to_s
  subject
end

#type(t = nil) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/publisci/metadata/prov/agent.rb', line 8

def type(t=nil)
  if t
    @type = t.to_sym
  else
    @type
  end
end

#type=(t) ⇒ Object



16
17
18
# File 'lib/publisci/metadata/prov/agent.rb', line 16

def type=(t)
  @type = t.to_sym
end