Class: DerringDo::Campaign

Inherits:
Object show all
Defined in:
lib/derring-do.rb

Constant Summary collapse

PANIC_WORDS =
[
  "Retreat!",
  "Thomas Jefferson...still survives...",
  "Nothing...but death.",
  "Et tu, Brute?",
  "I have tried so hard to do the right!",
  "They couldn't hit an elephant at this dist--",
]
INSULTS_ADJECTIVES =
%w(yellow-bellied two-faced two-timing no-good spineless)
INSULTS_NOUNS =
["coward", "Benedict Arnold", "traitor", "wimp"]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCampaign

Returns a new instance of Campaign.



16
17
18
19
20
21
# File 'lib/derring-do.rb', line 16

def initialize
  @progress = 0
  @target = nil
  @last_update_at = Time.now - DerringDo.configuration[:update_wait_time]
  @last_minor_update_at = Time.now - DerringDo.configuration[:minor_wait_time]
end

Instance Attribute Details

#progressObject (readonly)

Returns the value of attribute progress.



13
14
15
# File 'lib/derring-do.rb', line 13

def progress
  @progress
end

#targetObject

Returns the value of attribute target.



14
15
16
# File 'lib/derring-do.rb', line 14

def target
  @target
end

Instance Method Details

#aborted!Object

:nodoc:



45
46
47
48
49
# File 'lib/derring-do.rb', line 45

def aborted! #:nodoc:
  adj = INSULTS_ADJECTIVES.sort_by { rand }[0,3].join(", ")
  noun = INSULTS_NOUNS[rand(INSULTS_NOUNS.length)]
  DerringDo.configuration[:output_to].puts(adj + " " + noun + "!")
end

#failed_with(error) ⇒ Object

:nodoc:



37
38
39
40
# File 'lib/derring-do.rb', line 37

def failed_with(error) #:nodoc:
  panic = PANIC_WORDS[rand(PANIC_WORDS.length)]
  DerringDo.configuration[:output_to].puts(panic)
end

#tally_ho!(n = 1) ⇒ Object



23
24
25
26
# File 'lib/derring-do.rb', line 23

def tally_ho!(n=1)
  @progress += n
  inform_if_ready
end