Class: TyranoDsl::WritingContext
- Inherits:
-
Object
- Object
- TyranoDsl::WritingContext
- Defined in:
- lib/tyrano_dsl/writing_context.rb
Overview
Context for writing
Instance Attribute Summary collapse
- #current_scene_assets ⇒ Array<String> readonly
- #current_scene_content ⇒ Array<String> readonly
- #file_actions ⇒ Hash{String => Object} readonly
- #world ⇒ TyranoDsl::Elements::World readonly
Instance Method Summary collapse
-
#add_asset_loading(word_location, asset_content) ⇒ void
Add an asset to be loaded in the current scene.
-
#add_label(word_location, label_name) ⇒ void
Add an label in the current scene.
-
#append_content(word_location, content) ⇒ void
Append some content to the current scene.
-
#end_writing ⇒ void
Bookkeeping stuff to end the writing.
-
#init_new_scene(scene_name) ⇒ void
Initialize a new scene.
-
#initialize(world) ⇒ WritingContext
constructor
A new instance of WritingContext.
Constructor Details
#initialize(world) ⇒ WritingContext
Returns a new instance of WritingContext.
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/tyrano_dsl/writing_context.rb', line 21 def initialize(world) @logger = Logger.new(STDOUT) @world = world @file_actions = [] @current_scene_content = nil @current_scene_name = nil @current_scene_assets = nil @current_scene_labels = nil @scene_writer = TyranoDsl::ElementsWriters::SceneWriter.new end |
Instance Attribute Details
#current_scene_assets ⇒ Array<String> (readonly)
12 13 14 |
# File 'lib/tyrano_dsl/writing_context.rb', line 12 def current_scene_assets @current_scene_assets end |
#current_scene_content ⇒ Array<String> (readonly)
14 15 16 |
# File 'lib/tyrano_dsl/writing_context.rb', line 14 def current_scene_content @current_scene_content end |
#file_actions ⇒ Hash{String => Object} (readonly)
16 17 18 |
# File 'lib/tyrano_dsl/writing_context.rb', line 16 def file_actions @file_actions end |
#world ⇒ TyranoDsl::Elements::World (readonly)
18 19 20 |
# File 'lib/tyrano_dsl/writing_context.rb', line 18 def world @world end |
Instance Method Details
#add_asset_loading(word_location, asset_content) ⇒ void
This method returns an undefined value.
Add an asset to be loaded in the current scene
49 50 51 52 |
# File 'lib/tyrano_dsl/writing_context.rb', line 49 def add_asset_loading(word_location, asset_content) check_in_scene(word_location) @current_scene_assets << asset_content end |
#add_label(word_location, label_name) ⇒ void
This method returns an undefined value.
Add an label in the current scene
60 61 62 63 64 65 66 |
# File 'lib/tyrano_dsl/writing_context.rb', line 60 def add_label(word_location, label_name) check_in_scene(word_location) if @current_scene_labels.include? label_name raise TyranoDsl::TyranoException, "Duplicated label [#{label_name}]" end @current_scene_labels << label_name end |
#append_content(word_location, content) ⇒ void
This method returns an undefined value.
Append some content to the current scene
38 39 40 41 |
# File 'lib/tyrano_dsl/writing_context.rb', line 38 def append_content(word_location, content) check_in_scene(word_location) @current_scene_content << content end |
#end_writing ⇒ void
This method returns an undefined value.
Bookkeeping stuff to end the writing
82 83 84 85 86 87 88 89 90 |
# File 'lib/tyrano_dsl/writing_context.rb', line 82 def end_writing write_current_scene @current_scene_content = nil @current_scene_name = nil @current_scene_assets = nil @current_scene_labels = nil @world.validate log {"Writing is over, #{@file_actions.length} actions created"} end |
#init_new_scene(scene_name) ⇒ void
This method returns an undefined value.
Initialize a new scene
71 72 73 74 75 76 77 |
# File 'lib/tyrano_dsl/writing_context.rb', line 71 def init_new_scene(scene_name) write_current_scene @current_scene_content = [] @current_scene_name = scene_name @current_scene_assets = Set.new @current_scene_labels = [] end |