Method: Zold::Farm#initialize

Defined in:
lib/zold/node/farm.rb

#initialize(invoice, cache = File.join(Dir.pwd, 'farm'), log: Log::NULL, farmer: Farmers::Plain.new, lifetime: 24 * 60 * 60, strength: Score::STRENGTH) ⇒ Farm

Makes an instance of a farm. There should be only farm in the entire application, but you can, of course, start as many of them as necessary for the purpose of unit testing.

cache is the file where the farm will keep all the scores it manages to find. If the file is absent, it will be created, together with the necessary parent directories.

lifetime is the amount of seconds for a score to live in the farm, by default it’s the entire day, since the Score expires in 24 hours; can be decreased for the purpose of unit testing.



61
62
63
64
65
66
67
68
69
70
71
# File 'lib/zold/node/farm.rb', line 61

def initialize(invoice, cache = File.join(Dir.pwd, 'farm'), log: Log::NULL,
  farmer: Farmers::Plain.new, lifetime: 24 * 60 * 60, strength: Score::STRENGTH)
  @log = log
  @cache = File.expand_path(cache)
  @invoice = invoice
  @pipeline = Queue.new
  @farmer = farmer
  @threads = ThreadPool.new('farm', log: log)
  @lifetime = lifetime
  @strength = strength
end