Class: ShintyokuDoudesuka::Talk

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

Constant Summary collapse

SPEED =
3.0

Instance Method Summary collapse

Constructor Details

#initializeTalk

Returns a new instance of Talk.



7
8
9
10
# File 'lib/shintyoku_doudesuka.rb', line 7

def initialize
  @step = 0.0
  @speed = SPEED
end

Instance Method Details

#commentObject



34
35
36
37
38
39
40
41
42
# File 'lib/shintyoku_doudesuka.rb', line 34

def comment
  print "#{min[@step.to_i,100]}% "
  print '進捗どうですか > '
  if @speed > 2.0
    print 'いい感じです'
  else
    print 'ダメです'
  end
end

#finished?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/shintyoku_doudesuka.rb', line 30

def finished?
  @step >= 100
end

#raise_problemObject



22
23
24
# File 'lib/shintyoku_doudesuka.rb', line 22

def raise_problem
  @speed = SPEED * rand(10) * 0.1
end

#recoverObject



26
27
28
# File 'lib/shintyoku_doudesuka.rb', line 26

def recover
  @speed = SPEED
end

#showObject



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

def show
  l = (@step/5).to_i
  print "[#{"="*l}#{" "*(20-l)}] "
end

#succeedObject



12
13
14
15
# File 'lib/shintyoku_doudesuka.rb', line 12

def succeed
  @step += @speed
  show
end