Module: Demiurge::DSL
- Defined in:
- lib/demiurge/dsl.rb,
lib/demiurge/tmx.rb
Overview
This module contains the Builder classes that parse the World File DSL.
Defined Under Namespace
Classes: ActionItemBuilder, AgentBuilder, LocationBuilder, TmxLocationBuilder, TopLevelBuilder, ZoneBuilder
Class Method Summary collapse
-
.engine_from_dsl_files(*filenames) ⇒ Demiurge::Engine
This is a primary method for creating a new Demiurge Engine.
-
.engine_from_dsl_text(*specs) ⇒ Demiurge::Engine
This method takes either strings containing World File DSL text, or name/string pairs.
Class Method Details
.engine_from_dsl_files(*filenames) ⇒ Demiurge::Engine
This is a primary method for creating a new Demiurge Engine. It should be passed a list of filenames to load World File DSL from. It will return a fully-configured Engine which has called finished_init. If the Engine should load from an existing state-dump, that can be accomplished via load_state_from_dump.
171 172 173 174 |
# File 'lib/demiurge/dsl.rb', line 171 def self.engine_from_dsl_files(*filenames) filename_string_pairs = filenames.flatten.map { |fn| [fn, File.read(fn)] } engine_from_dsl_text(*filename_string_pairs) end |
.engine_from_dsl_text(*specs) ⇒ Demiurge::Engine
This method takes either strings containing World File DSL text, or name/string pairs. If a pair is supplied, the name gives the origin of the text for error messages.
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
# File 'lib/demiurge/dsl.rb', line 186 def self.engine_from_dsl_text(*specs) builder = Demiurge::DSL::TopLevelBuilder.new specs.each do |spec| if spec.is_a?(String) builder.instance_eval spec elsif spec.is_a?(Array) if spec.size != 2 raise "Not sure what to do with a #{spec.size}-elt array, normally this is a filename/string pair!" end builder.instance_eval spec[1], spec[0] else raise "Not sure what to do in engine_from_dsl_text with a #{spec.class}!" end end builder.built_engine end |