Class: Quby::Questionnaires::Entities::ScoreCalculation

Inherits:
Object
  • Object
show all
Defined in:
lib/quby/questionnaires/entities/score_calculation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, options, &block) ⇒ ScoreCalculation

Returns a new instance of ScoreCalculation.



37
38
39
40
41
42
43
44
# File 'lib/quby/questionnaires/entities/score_calculation.rb', line 37

def initialize(key, options, &block)
  @key = key
  @label = options[:label]
  @sbg_key = options[:sbg_key]
  @options = options[:options] || options # TODO remove `|| options`
  @sourcecode = options[:sourcecode]
  @block = block
end

Instance Attribute Details

#keyObject

Returns the value of attribute key.



35
36
37
# File 'lib/quby/questionnaires/entities/score_calculation.rb', line 35

def key
  @key
end

#labelObject

Returns the value of attribute label.



35
36
37
# File 'lib/quby/questionnaires/entities/score_calculation.rb', line 35

def label
  @label
end

#optionsObject

Returns the value of attribute options.



35
36
37
# File 'lib/quby/questionnaires/entities/score_calculation.rb', line 35

def options
  @options
end

#sbg_keyObject

Returns the value of attribute sbg_key.



35
36
37
# File 'lib/quby/questionnaires/entities/score_calculation.rb', line 35

def sbg_key
  @sbg_key
end

Instance Method Details

#actionObject



62
63
64
# File 'lib/quby/questionnaires/entities/score_calculation.rb', line 62

def action
  @options[:action]
end

#calculationObject



46
47
48
49
50
51
52
# File 'lib/quby/questionnaires/entities/score_calculation.rb', line 46

def calculation
  if @block
    @block
  else
    StripOuterScoreCall.instance_eval(@sourcecode)
  end
end

#completionObject



58
59
60
# File 'lib/quby/questionnaires/entities/score_calculation.rb', line 58

def completion
  @options[:completion]
end

#scoreObject



54
55
56
# File 'lib/quby/questionnaires/entities/score_calculation.rb', line 54

def score
  @options[:score]
end