Class: Calculus::ManureManagementPlan::Method

Inherits:
Object
  • Object
show all
Defined in:
lib/calculus/manure_management_plan/method.rb

Direct Known Subclasses

External

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Method

Returns a new instance of Method.


4
5
6
7
8
9
10
11
12
13
# File 'lib/calculus/manure_management_plan/method.rb', line 4

def initialize(options = {})
  @options        = options
  @variety        = options[:variety]
  @support        = options[:support]
  @opened_at      = options[:opened_at]
  @usage          = options[:production_usage]
  @soil_nature    = options[:soil_nature]
  @cultivation    = options[:cultivation]
  @expected_yield = options[:expected_yield] || 0.0.in_kilogram_per_square_meter
end

Instance Method Details

#computeObject

Raises:

  • (NotImplemented)

42
43
44
# File 'lib/calculus/manure_management_plan/method.rb', line 42

def compute
  raise NotImplemented
end

#crop_setsObject

Returns matching crop set for the given variety


28
29
30
31
32
33
34
35
36
# File 'lib/calculus/manure_management_plan/method.rb', line 28

def crop_sets
  return [] unless @variety
  @crop_sets ||= Nomen::CropSet.list.select do |i|
    i.varieties.detect do |v|
      @variety <= v
    end
  end
  @crop_sets
end

#estimate_expected_yieldObject

Raises:

  • (NotImplemented)

38
39
40
# File 'lib/calculus/manure_management_plan/method.rb', line 38

def estimate_expected_yield
  raise NotImplemented
end

#productionObject


19
20
21
# File 'lib/calculus/manure_management_plan/method.rb', line 19

def production
  @support.activity
end

#soil_naturesObject


23
24
25
# File 'lib/calculus/manure_management_plan/method.rb', line 23

def soil_natures
  @soil_natures ||= (@options[:soil_nature] ? @options[:soil_nature].self_and_parents : [:undefined])
end