Class: Model::Ontology
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#facts_only, #graph, #method_missing
Constructor Details
#initialize(repository, n3_input = nil) ⇒ Ontology
Returns a new instance of Ontology.
16
17
18
19
20
|
# File 'lib/models/ontology.rb', line 16
def initialize(repository, n3_input = nil)
@repository = repository
load_and_process_n3 n3_input if n3_input
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class RepositoryProxy
Instance Attribute Details
#repository ⇒ Object
Returns the value of attribute repository.
8
9
10
|
# File 'lib/models/ontology.rb', line 8
def repository
@repository
end
|
Class Method Details
.from_n3(n3_input) ⇒ Object
12
13
14
|
# File 'lib/models/ontology.rb', line 12
def self.from_n3(n3_input)
Ontology.new(RDF::Repository.new, n3_input)
end
|
Instance Method Details
#applications ⇒ Object
27
28
29
30
31
32
|
# File 'lib/models/ontology.rb', line 27
def applications
query([nil, RDF.type, LV.Application]).
map(&:subject).uniq.map do |subject|
Application.new(subject, self)
end
end
|
#device_with_description(description) ⇒ Object
58
59
60
|
# File 'lib/models/ontology.rb', line 58
def device_with_description(description)
devices.find { |d| d.description == description }
end
|
#devices ⇒ Object
40
41
42
43
44
|
# File 'lib/models/ontology.rb', line 40
def devices
query([nil, RDF.type, LV.Device]).map do |statement|
Device.new(statement.subject, self)
end
end
|
#installations ⇒ Object
34
35
36
37
38
|
# File 'lib/models/ontology.rb', line 34
def installations
query([nil, RDF.type, LV.Installation]).map do |statement|
Installation.new(statement.subject, self)
end
end
|
#load_and_process_n3(n3_input) ⇒ Object
22
23
24
25
|
# File 'lib/models/ontology.rb', line 22
def load_and_process_n3(n3_input)
(@n3_inputs ||= []) << n3_input
refresh
end
|
#properties ⇒ Object
52
53
54
55
56
|
# File 'lib/models/ontology.rb', line 52
def properties
query([nil, RDF.type, LV.Property]).map do |statement|
Property.new(statement.subject, self)
end
end
|
#scenarios ⇒ Object
46
47
48
49
50
|
# File 'lib/models/ontology.rb', line 46
def scenarios
query([nil, RDF.type, LV.Scenario]).map do |statement|
Scenario.new(statement.subject, self)
end
end
|