Class: Gamefic::Scene::YesOrNo
Overview
Prompt the user to answer “yes” or “no”. The scene will accept variations like “YES” or “n” and normalize the answer to “yes” or “no” in the finish block. After the scene is finished, the :active scene will be cued if no other scene has been prepared or cued.
Instance Attribute Summary
Attributes inherited from Base
#actor, #input, #type
Instance Method Summary
collapse
Methods inherited from Base
#flush, #initialize, initialize_block, #on_finish, on_initialize, #start, #state, subclass, #update
Instance Method Details
#finish ⇒ Object
30
31
32
33
34
35
36
|
# File 'lib/gamefic/scene/yes_or_no.rb', line 30
def finish
if yes? or no?
super
else
actor.tell invalid_message
end
end
|
#invalid_message ⇒ Object
22
23
24
|
# File 'lib/gamefic/scene/yes_or_no.rb', line 22
def invalid_message
@invalid_message ||= 'Please enter Yes or No.'
end
|
#no? ⇒ Boolean
18
19
20
|
# File 'lib/gamefic/scene/yes_or_no.rb', line 18
def no?
input.to_s[0,1].downcase == 'n'
end
|
#post_initialize ⇒ Object
9
10
11
12
|
# File 'lib/gamefic/scene/yes_or_no.rb', line 9
def post_initialize
self.type = 'YesOrNo'
self.prompt = 'Yes or No?'
end
|
#prompt ⇒ Object
26
27
28
|
# File 'lib/gamefic/scene/yes_or_no.rb', line 26
def prompt
@prompt ||= 'Yes or No?'
end
|
#yes? ⇒ Boolean
14
15
16
|
# File 'lib/gamefic/scene/yes_or_no.rb', line 14
def yes?
input.to_s[0,1].downcase == 'y'
end
|