Class: Objective
Constant Summary collapse
- @@objectives =
class array holds instances of objectives one per .goal file
Array.new
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#outcomes ⇒ Object
readonly
Returns the value of attribute outcomes.
Class Method Summary collapse
-
.add_current(name) ⇒ Object
needs to just be adding 1.
- .get_all ⇒ Object
- .get_current ⇒ Object
Instance Method Summary collapse
- #==(other) ⇒ Object
- #add_outcome(outcome) ⇒ Object
-
#initialize(name) ⇒ Objective
constructor
A new instance of Objective.
-
#save ⇒ Object
persist the results.
- #state ⇒ Object
Constructor Details
#initialize(name) ⇒ Objective
Returns a new instance of Objective.
29 30 31 32 |
# File 'lib/mobiusloop/objective.rb', line 29 def initialize(name) @name = name @outcomes = [] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
26 27 28 |
# File 'lib/mobiusloop/objective.rb', line 26 def name @name end |
#outcomes ⇒ Object (readonly)
Returns the value of attribute outcomes.
27 28 29 |
# File 'lib/mobiusloop/objective.rb', line 27 def outcomes @outcomes end |
Class Method Details
.add_current(name) ⇒ Object
needs to just be adding 1
9 10 11 12 13 14 15 |
# File 'lib/mobiusloop/objective.rb', line 9 def self.add_current(name) objective = Objective.new(name) if @@objectives.include?(objective) == false @@objectives.push(objective) end self.get_current end |
.get_all ⇒ Object
21 22 23 |
# File 'lib/mobiusloop/objective.rb', line 21 def self.get_all @@objectives end |
.get_current ⇒ Object
17 18 19 |
# File 'lib/mobiusloop/objective.rb', line 17 def self.get_current @@objectives.last end |
Instance Method Details
#==(other) ⇒ Object
67 68 69 |
# File 'lib/mobiusloop/objective.rb', line 67 def ==(other) other.class == self.class && other.name == self.name end |
#add_outcome(outcome) ⇒ Object
35 36 37 |
# File 'lib/mobiusloop/objective.rb', line 35 def add_outcome(outcome) @outcomes.push(outcome) end |
#save ⇒ Object
persist the results. May be overridden by subclasses
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/mobiusloop/objective.rb', line 41 def save filename = Time.now.strftime("measures-%Y-%m-%d-%H%M%S.json") dirname = "goals/measures" hash = { "objective" => @name} @outcomes.each {|o| hash.store("outcome", o.name) hash.store("scale", "#{o.scale.class.name}.rb") hash.store("baseline", o.baseline) hash.store("baseline date", o.baseline_date) hash.store("target", o.target) hash.store("target date", o.target_date) hash.store("measure", o.last_measure.value) hash.store("measure date", Time.now.strftime("%b %-d, %Y")) } if !File.exists? dirname FileUtils.mkdir_p dirname end File.open("#{dirname}/#{filename}","a") do |f| f.write(JSON.pretty_generate(hash)) f.write("\n") end end |
#state ⇒ Object
72 73 74 |
# File 'lib/mobiusloop/objective.rb', line 72 def state self.instance_variables.map { |variable| self.instance_variable_get variable } end |