Module: StoryTeller::Library::Bootstrap
- Defined in:
- lib/story_teller/library/bootstrap.rb
Overview
The StoryTeller::Library::Bootstrap module
Class Method Summary collapse
- .ensure_location(inflib) ⇒ Object
-
.manage_inform_library(player: nil, key: StoryTeller::Engine, &block) ⇒ Object
rubocop: disable Metrics/MethodLength.
- .set_selfobj(inflib, player) ⇒ Object
Class Method Details
.ensure_location(inflib) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/story_teller/library/bootstrap.rb', line 30 def ensure_location(inflib) return if inflib.nil? return if inflib.location player_obj = inflib.player location = player_obj&.location location ||= player_obj&.spawn_point if player_obj.respond_to?(:spawn_point) inflib.instance_variable_set(:@location, location) end |
.manage_inform_library(player: nil, key: StoryTeller::Engine, &block) ⇒ Object
rubocop: disable Metrics/MethodLength
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/story_teller/library/bootstrap.rb', line 45 def manage_inform_library(player: nil, key: StoryTeller::Engine, &block) inflib = StoryTeller::Engine.libraries[key] unless inflib.nil? || player.nil? set_selfobj(inflib, player) return inflib end inflib = block_given? ? block.call : InformLibrary.new return nil if inflib.nil? set_selfobj(inflib, player) inflib.subscribe(inflib.selfobj) ensure_location(inflib) StoryTeller::Engine.libraries[key] = inflib end |
.set_selfobj(inflib, player) ⇒ Object
40 41 42 |
# File 'lib/story_teller/library/bootstrap.rb', line 40 def set_selfobj(inflib, player) inflib.selfobj = player unless player.nil? end |