Class: Cirrocumulus::Environment

Inherits:
Object
  • Object
show all
Defined in:
lib/cirrocumulus/environment.rb

Overview

Cirrocumulus environment. It is a container where all ontologies will be loaded.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Environment

Returns a new instance of Environment.



15
16
17
18
19
20
21
# File 'lib/cirrocumulus/environment.rb', line 15

def initialize(name)
  Log4r::Logger['agent'].info "Loading #{name} Cirrocumulus environment"

  @name = name
  @ontologies = []
  @@instance = self
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



13
14
15
# File 'lib/cirrocumulus/environment.rb', line 13

def name
  @name
end

Class Method Details

.currentObject



9
10
11
# File 'lib/cirrocumulus/environment.rb', line 9

def self.current
  @@instance
end

Instance Method Details

#joinObject



39
40
41
# File 'lib/cirrocumulus/environment.rb', line 39

def join
  @ontologies.each {|ontology| ontology.join }
end

#load_ontology(ontology_instance) ⇒ Object

Loads ontology instance into environment.



26
27
28
29
# File 'lib/cirrocumulus/environment.rb', line 26

def load_ontology(ontology_instance)
  Log4r::Logger['agent'].info "Adding #{ontology_instance.name} ontology"
  @ontologies << ontology_instance
end

#runObject

Runs the environment. It will also restore all loaded ontologies states.



34
35
36
37
# File 'lib/cirrocumulus/environment.rb', line 34

def run
  @ontologies.each {|ontology| ontology.restore_state }
  @ontologies.each {|ontology| ontology.run }
end