Class: VirtualAssembly::Semantizer::SemanticProperty
- Inherits:
-
Object
- Object
- VirtualAssembly::Semantizer::SemanticProperty
- Defined in:
- lib/virtual_assembly/semantizer/semantic_property.rb
Overview
The SemanticPropety class is designed to turn properties of objects into linked data.
A SemanticProperty has a name and a corresponding value that can be fetched later (so its value would be up to date).
This class is intented to be used through the SemanticObject class.
For instance, we can tell that the name of a Person object refers to the linked data concept “name” from the FOAF project. The name of the property would be the uri of the FOAF:name property while the value would be the attribute reader of the name of the Person object.
You should use a block to pass the value like so: SemanticProperty.new(“xmlns.com/foaf/0.1/name”) selfself.name
Instance Attribute Summary collapse
-
#name ⇒ Object
The name of the property.
-
#valueGetter ⇒ Object
The function to call when the value is requested.
Instance Method Summary collapse
-
#initialize(name, &valueGetter) ⇒ SemanticProperty
constructor
“xmlns.com/foaf/0.1/name” or “@id” for instance.
-
#value ⇒ Object
Fetch and returns the value associated to this property.
Constructor Details
#initialize(name, &valueGetter) ⇒ SemanticProperty
“xmlns.com/foaf/0.1/name” or “@id” for instance.
property when requested.
53 54 55 56 |
# File 'lib/virtual_assembly/semantizer/semantic_property.rb', line 53 def initialize(name, &valueGetter) @name = name @valueGetter = valueGetter end |
Instance Attribute Details
#name ⇒ Object
The name of the property. It generally points to an uri like “xmlns.com/foaf/0.1/name” or it is used to define a reserved linked data property like “@id”.
This should be a String.
41 42 43 |
# File 'lib/virtual_assembly/semantizer/semantic_property.rb', line 41 def name @name end |
#valueGetter ⇒ Object
The function to call when the value is requested.
This should be a Proc passed as a Block.
46 47 48 |
# File 'lib/virtual_assembly/semantizer/semantic_property.rb', line 46 def valueGetter @valueGetter end |
Instance Method Details
#value ⇒ Object
Fetch and returns the value associated to this property.
59 60 61 |
# File 'lib/virtual_assembly/semantizer/semantic_property.rb', line 59 def value return @valueGetter.call end |