Class: ODRL::Profile::Rule

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

Overview

This class MUST NOT be used to add custom ODRL Rules. Instead, sublcasses of this class offered by the builder must be used. This class is used to define the common properties of ODRL rules. E.g: In a Policy, the newly CustomPermission has been created and can be used as follows: ex:myPolicy odrl:permission ex:myPermission . ex:myPermission a ex-profile:CustomPermission ; odrl:target <example.com/asset_01> …

Direct Known Subclasses

Duty, Permission, Prohibition

Instance Attribute Summary collapse

Attributes inherited from ProfileElement

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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Rule.



215
216
217
218
219
# File 'lib/odrl/profile/builder.rb', line 215

def initialize(disjoints: [], **args)
  @disjoints = disjoints

  super(**args)
end

Instance Attribute Details

#disjointsObject

Returns the value of attribute disjoints.



213
214
215
# File 'lib/odrl/profile/builder.rb', line 213

def disjoints
  @disjoints
end

Instance Method Details

#build(repo:) ⇒ Object



221
222
223
224
225
226
227
228
229
230
231
# File 'lib/odrl/profile/builder.rb', line 221

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)

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