class Gamefic::Scene::YesOrNo

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.

Attributes

invalid_message[W]

Public Instance Methods

finish() click to toggle source
Calls superclass method Gamefic::Scene::Base#finish
# File lib/gamefic/scene/yes_or_no.rb, line 39
def finish
  if yes? or no?
    super
  else
    actor.tell invalid_message
  end
end
invalid_message() click to toggle source

The message sent to the user for an invalid answer, i.e., the input could not be resolved to either Yes or No.

@return [String]

# File lib/gamefic/scene/yes_or_no.rb, line 35
def invalid_message
  @invalid_message ||= 'Please enter Yes or No.'
end
no?() click to toggle source

True if the actor's answer is No. Any answer beginning with letter N is considered No.

@return [Boolean]

# File lib/gamefic/scene/yes_or_no.rb, line 27
def no?
  input.to_s[0,1].downcase == 'n' or input.to_i == 2
end
post_initialize() click to toggle source
# File lib/gamefic/scene/yes_or_no.rb, line 10
def post_initialize
  self.type = 'YesOrNo'
  self.prompt = 'Yes or No:'
end
state() click to toggle source
Calls superclass method Gamefic::Scene::Base#state
# File lib/gamefic/scene/yes_or_no.rb, line 47
def state
  super.merge options: ['Yes', 'No']
end
yes?() click to toggle source

True if the actor's answer is Yes. Any answer beginning with letter Y is considered Yes.

@return [Boolean]

# File lib/gamefic/scene/yes_or_no.rb, line 19
def yes?
  input.to_s[0,1].downcase == 'y' or input.to_i == 1
end