Class: VirtualAssembly::Semantizer::SemanticProperty

Inherits:
Object
  • Object
show all
Defined in:
lib/virtual_assembly/semantizer/semantic_property.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, &valueGetter) ⇒ SemanticProperty

xmlns.com/foaf/0.1/name” or “@id” for instance.

property when requested.

Parameters:

  • name

    The name of the property, like

  • valueGetter

    A Proc used to retrieve the value of the



61
62
63
64
# File 'lib/virtual_assembly/semantizer/semantic_property.rb', line 61

def initialize(name, &valueGetter)
  @name = name
  @valueGetter = valueGetter
end

Instance Attribute Details

#nameObject

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.



44
45
46
# File 'lib/virtual_assembly/semantizer/semantic_property.rb', line 44

def name
  @name
end

#valueGetterObject

The function to call when the value is requested.

This should be a Proc passed as a Block.



49
50
51
# File 'lib/virtual_assembly/semantizer/semantic_property.rb', line 49

def valueGetter
  @valueGetter
end

#valueSetterObject

The function to call to store a new value.

This should be a Proc



54
55
56
# File 'lib/virtual_assembly/semantizer/semantic_property.rb', line 54

def valueSetter
  @valueSetter
end

Instance Method Details

#==(other) ⇒ Object



76
77
78
# File 'lib/virtual_assembly/semantizer/semantic_property.rb', line 76

def ==(other)
  other && name == other.name && value == other.value
end

#valueObject

Fetch and returns the value associated to this property.



67
68
69
# File 'lib/virtual_assembly/semantizer/semantic_property.rb', line 67

def value
  @valueGetter.call
end

#value=(new_value) ⇒ Object

Stores a new value for this property.



72
73
74
# File 'lib/virtual_assembly/semantizer/semantic_property.rb', line 72

def value=(new_value)
  @valueSetter.call(new_value)
end