Class: Rubygoal::Goal

Inherits:
Object
  • Object
show all
Defined in:
lib/rubygoal/goal.rb

Instance Method Summary collapse

Constructor Details

#initializeGoal

Returns a new instance of Goal.



5
6
7
# File 'lib/rubygoal/goal.rb', line 5

def initialize
  @celebration_time = 0
end

Instance Method Details

#celebrating?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/rubygoal/goal.rb', line 9

def celebrating?
  celebration_time > 0
end

#start_celebrationObject



13
14
15
# File 'lib/rubygoal/goal.rb', line 13

def start_celebration
  self.celebration_time = 3
end

#update(elapsed_time) ⇒ Object



17
18
19
20
# File 'lib/rubygoal/goal.rb', line 17

def update(elapsed_time)
  start_celebration unless celebrating?
  self.celebration_time -= elapsed_time
end