Class: PubliSci::Prov::Derivation

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

Instance Method Summary collapse

Methods included from CustomPredicate

#add_custom, #custom, #has

Instance Method Details

#__labelObject



7
8
9
10
# File 'lib/publisci/metadata/prov/derivation.rb', line 7

def __label
  # raise "MissingInternalLabel: no __label for #{self.inspect}" unless @__label
  @__label ||= Time.now.nsec.to_s(32)
end

#entity(entity = nil) ⇒ Object Also known as: data



32
33
34
35
36
37
38
39
40
41
# File 'lib/publisci/metadata/prov/derivation.rb', line 32

def entity(entity=nil)
  if entity
    @entity = entity
  elsif @entity.is_a? Symbol
    raise "UnknownEntity #{@entity}" unless Prov.entities[@entity]
    @entity = Prov.entities[@entity]
  else
    @entity
  end
end

#had_activity(activity = nil) ⇒ Object Also known as: activity



20
21
22
23
24
25
26
27
28
29
# File 'lib/publisci/metadata/prov/derivation.rb', line 20

def had_activity(activity=nil)
  if activity
    @had_activity = activity
  elsif @had_activity.is_a? Symbol
    raise "UnknownActivity #{@had_activity}" unless Prov.activities[@had_activity]
    @had_activity = Prov.activities[@had_activity]
  else
    @had_activity
  end
end

#subject(sub = nil) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/publisci/metadata/prov/derivation.rb', line 12

def subject(sub=nil)
  if sub
    @subject = sub
  else
    @subject ||= "#{Prov.base_url}/derivation/#{Time.now.nsec.to_s(32)}"
  end
end

#to_n3Object



44
45
46
47
48
49
50
51
52
53
# File 'lib/publisci/metadata/prov/derivation.rb', line 44

def to_n3
  str = "<#{subject}> a prov:Derivation ;\n"
  str << "\tprov:entity <#{entity}> ;\n" if entity
  str << "\tprov:hadActivity <#{had_activity}> ;\n" if had_activity
  str << "\trdfs:label \"#{__label}\".\n\n"

  add_custom(str)

  str
end

#to_sObject



55
56
57
# File 'lib/publisci/metadata/prov/derivation.rb', line 55

def to_s
  subject
end