Class: Pdadv::Scenario

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeScenario

Returns a new instance of Scenario.



7
8
9
10
11
# File 'lib/pdadv/scenario.rb', line 7

def initialize
  @env = Pdadv::Environment.new
  @screens = []
  @registered_images = {}
end

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env.



12
13
14
# File 'lib/pdadv/scenario.rb', line 12

def env
  @env
end

#screensObject (readonly)

Returns the value of attribute screens.



12
13
14
# File 'lib/pdadv/scenario.rb', line 12

def screens
  @screens
end

Instance Method Details

#add_command(name, argv = []) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/pdadv/scenario.rb', line 32

def add_command(name, argv = [])
  case name.downcase
  when 'setglobal'
    add_set_global_command(argv)
  when 'register'
    add_register_command(argv)
  when 'back'
    add_back_command(argv)
  when 'show'
    add_show_command(argv)
  else
    puts "[unknown command]\t#{name}"
  end
end

#add_message(message) ⇒ Object



27
28
29
30
# File 'lib/pdadv/scenario.rb', line 27

def add_message(message)
  return if message.strip.empty?
  last_screen.message = message.strip
end

#asset_path(path) ⇒ Object



14
15
16
# File 'lib/pdadv/scenario.rb', line 14

def asset_path(path)
  File.expand_path(path, @env.base_path)
end

#enter_page(name = nil) ⇒ Object



23
24
25
# File 'lib/pdadv/scenario.rb', line 23

def enter_page(name = nil)
  @screens.push(Pdadv::Screen.new(name))
end

#last_screenObject



18
19
20
21
# File 'lib/pdadv/scenario.rb', line 18

def last_screen
  enter_page if screens.empty?
  @screens.last
end