Class: Pdadv::Scenario
- Inherits:
-
Object
- Object
- Pdadv::Scenario
- Defined in:
- lib/pdadv/scenario.rb
Instance Attribute Summary collapse
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#screens ⇒ Object
readonly
Returns the value of attribute screens.
Instance Method Summary collapse
- #add_command(name, argv = []) ⇒ Object
- #add_message(message) ⇒ Object
- #asset_path(path) ⇒ Object
- #enter_page(name = nil) ⇒ Object
-
#initialize ⇒ Scenario
constructor
A new instance of Scenario.
- #last_screen ⇒ Object
Constructor Details
#initialize ⇒ Scenario
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
#env ⇒ Object (readonly)
Returns the value of attribute env.
12 13 14 |
# File 'lib/pdadv/scenario.rb', line 12 def env @env end |
#screens ⇒ Object (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 () return if .strip.empty? last_screen. = .strip end |
#asset_path(path) ⇒ Object
14 15 16 |
# File 'lib/pdadv/scenario.rb', line 14 def asset_path(path) File.(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_screen ⇒ Object
18 19 20 21 |
# File 'lib/pdadv/scenario.rb', line 18 def last_screen enter_page if screens.empty? @screens.last end |