Module: QuestionChain::Answerable::InstanceMethods

Defined in:
lib/question_chain/answerable.rb

Instance Method Summary collapse

Instance Method Details

#_identifierObject

you should set this to be what stored identifier you  wish to have if you use more then 1 object in  your calculation



87
88
89
90
91
92
93
# File 'lib/question_chain/answerable.rb', line 87

def _identifier
  idents = []
  object_references.each_pair do |key, value|
    idents << value["identifier"]
  end
  idents.join(" ")
end

#add_extra_keywordsObject



52
53
54
55
56
57
58
# File 'lib/question_chain/answerable.rb', line 52

def add_extra_keywords
  unless (self.class._extra_keyword_methods || []).empty?
    self.class._extra_keyword_methods.each do |method|
     self._extra_keywords << self.send(method)
    end
  end
end

#ch4Object



103
104
105
# File 'lib/question_chain/answerable.rb', line 103

def ch4
  (result["calculations"]["ch4"]["value"] || 0).to_f
end

#co2Object



99
100
101
# File 'lib/question_chain/answerable.rb', line 99

def co2
  (result["calculations"]["co2"]["value"] || 0).to_f
end

#co2eObject



111
112
113
# File 'lib/question_chain/answerable.rb', line 111

def co2e
  (result["calculations"]["co2e"]["value"] || 0).to_f
end

#identifierObject



95
96
97
# File 'lib/question_chain/answerable.rb', line 95

def identifier
  _identifier == read_attribute(:stored_identifier) ? read_attribute(:stored_identifier) : _identifier
end

#n2oObject



107
108
109
# File 'lib/question_chain/answerable.rb', line 107

def n2o
  (result["calculations"]["n2o"]["value"]|| 0).to_f
end

#object_reference(object_reference_id = self.object_reference_id) ⇒ Object



68
69
70
# File 'lib/question_chain/answerable.rb', line 68

def object_reference(object_reference_id = self.object_reference_id)
  result["object_references"] && result["object_references"][object_reference_id]
end

#object_reference_characteristics(object_reference = self.object_reference) ⇒ Object



60
61
62
# File 'lib/question_chain/answerable.rb', line 60

def object_reference_characteristics(object_reference = self.object_reference)
  object_reference["characteristics"]
end

#object_reference_id(object_reference_name = self.object_reference_name) ⇒ Object



72
73
74
# File 'lib/question_chain/answerable.rb', line 72

def object_reference_id(object_reference_name = self.object_reference_name)
  answer_params[object_reference_name]
end

#object_reference_nameObject



76
77
78
# File 'lib/question_chain/answerable.rb', line 76

def object_reference_name
  # should be set in the answerable if want to use
end

#object_referencesObject



64
65
66
# File 'lib/question_chain/answerable.rb', line 64

def object_references
  result["object_references"]
end

#variable_inputObject



80
81
82
# File 'lib/question_chain/answerable.rb', line 80

def variable_input
  # should be set in the answerable if you want to use this
end