| Class | Gardener |
| In: |
lib/gardener.rb
|
| Parent: | Object |
This class provides the gardener part of the Gardener,Garden,Seed natural design patern
The Gardener act as the client class for accessing and assessing the Garden ressources. Its initialization occurs through the Abundance.gardener class method.
The Gardener‘s instance methods are:
| Author: | lp (lp@spiralix.org) |
| Copyright: | 2008 Louis-Philippe Perron - Released under the terms of the MIT license |
The new class method initializes the class. As part of the Abundance lib, Gardener is not initialized directly, but rather through Abundance.gardener.
gardener = Gardener.new({:wheelbarrow => 124, :rows => 6, :init_timeout}) { your_special_garden function }
The growth method for the Gardener instance allow to get report of the growing process
The parameter given as a symbol specifies the level of growth report you wish to get:
progress = gardener.growth(:progress)
puts "progress is now #{progress}" # => progress is now 0.75
The harvest method for the Gardener instance allow to get arrays of results for each queue level. It has two different behaviour on queue data, one for ripe elements where it removes them from crop array ( on seedID and :crop invocations ), for all other methods of invocation it leaves the queue intact.
The option given as a symbol specifies the level of queue results you wish to get:
When specifying :one as option, a seed ID is also required:
seed1_result = gardener.harvest(:one,id_seed_1)
The init_status method for the Gardener instance allow to harvest an initialisation status message that would have been set by the Abundance.init_status method, inside the Abundance.gardener‘s block. It returns an array of hash, one hash for each garden rows.
puts gardener.init_status.inspect # => [{:message=>"init ok", :success=>true, :pid=>4760}, {:message=>"init failed", :success=>false, :pid=>4761}]
The seed_all method allow to send a command to all row processes, usefull for a parameter change that needs to affect the prefered behaviour of all row. It returns an array containing hashes for each rows results.
result = gardener.seed_all("pref local") # => [{:success=>true, :message=>["row pref changed to local"], :seed=>"pref local", :pid=>14915},
{:success=>true, :message=>["row pref changed to local"], :seed=>"pref local", :pid=>14913}]