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



103
104
105
106
107
108
109
# File 'lib/question_chain/answerable.rb', line 103

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

#add_extra_keywordsObject



68
69
70
71
72
73
74
# File 'lib/question_chain/answerable.rb', line 68

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



119
120
121
# File 'lib/question_chain/answerable.rb', line 119

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

#co2Object



115
116
117
# File 'lib/question_chain/answerable.rb', line 115

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

#co2eObject



127
128
129
# File 'lib/question_chain/answerable.rb', line 127

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

#identifierObject



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

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

#n2oObject



123
124
125
# File 'lib/question_chain/answerable.rb', line 123

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

#object_reference(object_reference_id = self.object_reference_id) ⇒ Object



84
85
86
# File 'lib/question_chain/answerable.rb', line 84

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



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

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

#object_reference_id(object_reference_name = self.object_reference_name) ⇒ Object



88
89
90
# File 'lib/question_chain/answerable.rb', line 88

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

#object_reference_nameObject



92
93
94
# File 'lib/question_chain/answerable.rb', line 92

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

#object_referencesObject



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

def object_references
  result["object_references"]
end

#variable_inputObject



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

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