Class: ODRL::Action
Overview
ODRL::Action Describes an action like “use”
Instance Attribute Summary collapse
-
#(optional) ⇒ URI
uid the URI of the Action node.
-
#predicate ⇒ URI
(optional) the predicate you wish to use with this action.
-
#refinements ⇒ Object
Returns the value of attribute refinements.
-
#type ⇒ Object
Returns the value of attribute type.
-
#uid ⇒ Object
Returns the value of attribute uid.
-
#vallabel ⇒ string
(optional) a string like “use”.
-
#value ⇒ string
(required) a string like “use”.
Attributes inherited from Base
#baseURI, #creator, #description, #id, #issued, #label, #subject, #title
Instance Method Summary collapse
-
#addRefinement(refinement: args) ⇒ Object
Adds an ODRL Refinement.
-
#initialize(value:, vallabel: "", type: CACTION, **args) ⇒ Action
constructor
constructor.
-
#load_graph ⇒ Object
Causes the triples of this object to be formed in the in-memory store This includes any “cascading” objects for which this is the subject of the triple.
-
#serialize(format:) ⇒ Object
Returns the serialized RDF for this object and cascading related objects.
Methods inherited from Base
baseURI, clear_repository, #get_writer, getuuid, repository, #repository, #triplify
Constructor Details
#initialize(value:, vallabel: "", type: CACTION, **args) ⇒ Action
constructor
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/odrl/action.rb', line 21 def initialize(value:, vallabel: "", type: CACTION, **args) @value = value @vallabel = vallabel || @value raise "Actions must haves a value such as 'use' - I'm dead!" unless @value # if it is already a URI, then let it go @value = "http://www.w3.org/ns/odrl/2/#{@value}" unless @value =~ %r{http://} @uid = @value # unless @uid # self.uid = Base.baseURI + "#action_" + Base.getuuid # end super(uid: @uid, type: type, **args) @refinements = {} args[:refinements] = [args[:refinements]] unless args[:refinements].is_a? Array unless args[:refinements].first.nil? args[:refinements].each do |c| addRefinement(refinement: c) end end self.predicate = PACTION unless predicate end |
Instance Attribute Details
#(optional) ⇒ URI
uid the URI of the Action node
13 14 15 |
# File 'lib/odrl/action.rb', line 13
def (optional)
@(optional)
end
|
#predicate ⇒ URI
(optional) the predicate you wish to use with this action
13 14 15 |
# File 'lib/odrl/action.rb', line 13 def predicate @predicate end |
#refinements ⇒ Object
Returns the value of attribute refinements.
14 15 16 |
# File 'lib/odrl/action.rb', line 14 def refinements @refinements end |
#type ⇒ Object
Returns the value of attribute type.
14 15 16 |
# File 'lib/odrl/action.rb', line 14 def type @type end |
#uid ⇒ Object
Returns the value of attribute uid.
14 15 16 |
# File 'lib/odrl/action.rb', line 14 def uid @uid end |
#vallabel ⇒ string
(optional) a string like “use”
13 14 15 |
# File 'lib/odrl/action.rb', line 13 def vallabel @vallabel end |
#value ⇒ string
(required) a string like “use”
13 14 15 |
# File 'lib/odrl/action.rb', line 13 def value @value end |
Instance Method Details
#addRefinement(refinement: args) ⇒ Object
Adds an ODRL Refinement
51 52 53 54 55 |
# File 'lib/odrl/action.rb', line 51 def addRefinement(refinement: args) raise "Refinement is not an ODRL Constraint" unless refinement.is_a?(Constraint) refinements[refinement.uid] = [PREFINEMENT, refinement] end |
#load_graph ⇒ Object
Causes the triples of this object to be formed in the in-memory store This includes any “cascading” objects for which this is the subject of the triple
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/odrl/action.rb', line 60 def load_graph super # TODO: This is bad DRY!! Put the bulk of this method into the base object [:refinements].each do |connected_object_type| next unless send(connected_object_type) send(connected_object_type).each do |_uid, typedconnection| predicate, odrlobject = typedconnection # e.g. "refinement", RefinementObject object = odrlobject.uid subject = uid repo = repository triplify(subject, predicate, object, repo) odrlobject.load_graph # start the cascade end end subject = uid object = vallabel predicate = SCHEMA.name repo = repository triplify(subject, predicate, object, repo) object = vallabel predicate = RDFS.label repo = repository triplify(subject, predicate, object, repo) end |
#serialize(format:) ⇒ Object
Returns the serialized RDF for this object and cascading related objects
90 91 92 |
# File 'lib/odrl/action.rb', line 90 def serialize(format:) super end |