Class: Algo::Dsl
- Inherits:
-
Object
show all
- Includes:
- Cluster
- Defined in:
- lib/algo/dsl.rb,
lib/algo/dsl/cluster.rb,
lib/algo/dsl/network.rb,
lib/algo/dsl/service.rb
Defined Under Namespace
Modules: Cluster, Network, Service
Constant Summary
collapse
- CLUSTER_DEFAULT =
{}
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Cluster
#cluster
Constructor Details
#initialize(options) ⇒ Dsl
Returns a new instance of Dsl.
31
32
33
34
35
|
# File 'lib/algo/dsl.rb', line 31
def initialize(options)
@options = CLUSTER_DEFAULT.dup
@options.merge!(options)
@clusters = []
end
|
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
9
10
11
|
# File 'lib/algo/dsl.rb', line 9
def options
@options
end
|
Class Method Details
.load(options, path = nil) ⇒ Object
17
18
19
20
21
22
|
# File 'lib/algo/dsl.rb', line 17
def self.load(options, path = nil)
dsl = new(options).tap do |dsl|
dsl._load_from(path)
end
dsl.result
end
|
.load_text(options, text) ⇒ Object
24
25
26
27
28
29
|
# File 'lib/algo/dsl.rb', line 24
def self.load_text(options, text)
dsl = new(options).tap do |dsl|
dsl.instance_eval(text)
end
dsl.result
end
|
Instance Method Details
#_load_from(path) ⇒ Object
37
38
39
|
# File 'lib/algo/dsl.rb', line 37
def _load_from(path)
instance_eval(File.read(path), path) if path
end
|
#result ⇒ Object
13
14
15
|
# File 'lib/algo/dsl.rb', line 13
def result
@clusters
end
|