Class: PubliSci::Prov::Activity

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

Defined Under Namespace

Classes: Associations, Generations, Usages

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 Method Details

#associated_with(agent = nil, &block) ⇒ Object Also known as: wasAssociatedWith



35
36
37
# File 'lib/publisci/metadata/prov/activity.rb', line 35

def associated_with(agent=nil, &block)
  block_list(:associated,:associations,Association,Associations,agent,&block)
end

#generated(entity = nil) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/publisci/metadata/prov/activity.rb', line 26

def generated(entity=nil)
  if entity.is_a? Entity
    entity.generated_by self
  elsif Prov.entities[entity]
    Prov.entities[entity].generated_by self
  end
  basic_list(:generated,:entities,Generations,entity)
end

#to_n3Object



44
45
46
47
48
49
50
51
52
53
54
55
56
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
# File 'lib/publisci/metadata/prov/activity.rb', line 44

def to_n3
  str = "<#{subject}> a prov:Activity ;\n"

  if generated
    str << "\tprov:generated "
    generated.dereference.map{|src|
      str << "<#{src}>, "
    }
    str[-2]=" "
    str[-1]=";\n"
  end

  if used
    used.dereference.map{|u|
      if u.is_a? Usage
        str << "\tprov:used <#{u.entity}> ;\n"
        str << "\tprov:qualifiedUsage <#{u}> ;\n"
      else
        str << "\tprov:used <#{u}> ;\n"
      end
    }
  end

  if associated_with
    associated_with.dereference.map{|assoc|
      if assoc.is_a? Association
        str << "\tprov:wasAssociatedWith <#{assoc.agent}> ;\n"
        str << "\tprov:qualifiedAssociation <#{assoc}> ;\n"
      else
        str << "\tprov:wasAssociatedWith <#{assoc}> ;\n"
      end
    }
  end

  add_custom(str)

  str << "\trdfs:label \"#{__label}\" .\n\n"
end

#to_sObject



83
84
85
# File 'lib/publisci/metadata/prov/activity.rb', line 83

def to_s
  subject
end

#used(entity = nil, &block) ⇒ Object



40
41
42
# File 'lib/publisci/metadata/prov/activity.rb', line 40

def used(entity=nil, &block)
  block_list(:use,:usages,Usage,Usages,entity, &block)
end