Class: ODRL::Profile::Policy

Inherits:
ProfileElement show all
Defined in:
lib/odrl/profile/builder.rb

Instance Attribute Summary collapse

Attributes inherited from ProfileElement

#definition, #label, #parent_class, #parent_property, #uri

Instance Method Summary collapse

Constructor Details

#initialize(disjoints: [], **args) ⇒ Policy

Returns a new instance of Policy.



176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/odrl/profile/builder.rb', line 176

def initialize(disjoints: [], **args)
  # Additional disjoints can added for custom policies
  @disjoints = [
    ODRLV.Agreement,
    ODRLV.Offer,
    ODRLV.Privacy,
    ODRLV.Request,
    ODRLV.Ticket,
    ODRLV.Assertion
  ].concat(disjoints)

  super(**args)
end

Instance Attribute Details

#disjointsObject

Returns the value of attribute disjoints.



174
175
176
# File 'lib/odrl/profile/builder.rb', line 174

def disjoints
  @disjoints
end

Instance Method Details

#build(repo:) ⇒ Object

ex:myPolicy a odrl:Policy .



191
192
193
194
195
196
197
198
199
200
201
202
203
204
# File 'lib/odrl/profile/builder.rb', line 191

def build(repo:)
  ODRL::Profile::Builder.triplify(uri, RDF.type, RDFS.Class, repo)
  ODRL::Profile::Builder.triplify(uri, RDF.type, OWL.Class, repo)
  ODRL::Profile::Builder.triplify(uri, RDF.type, SKOS.Concept, repo)
  ODRL::Profile::Builder.triplify(uri, RDFS.label, label, repo)
  ODRL::Profile::Builder.triplify(uri, SKOS.defintion, definition, repo)

  # Required declarations of disjointedness
  ODRL::Profile::Builder.triplify(uri, RDFS.subClassOf, ODRLV.Policy, repo)

  @disjoints.each do |disjoint|
    ODRL::Profile::Builder.triplify(uri, OWL.disjointWith, disjoint, repo)
  end
end