Module: TyranoDsl::WritingWords::WritingWordsModule

Included in:
AskQuestion, ConditionalJump, Jump, UpdateVariable
Defined in:
lib/tyrano_dsl/writing_words/writing_words_module.rb

Overview

A module to help writing writing word

Instance Method Summary collapse

Instance Method Details

#fetch_scene(world, word_location, scene_name) ⇒ TyranoDsl::Elements::Scene

Get a scene from its name

Parameters:

Returns:

Raises:



15
16
17
18
19
20
21
# File 'lib/tyrano_dsl/writing_words/writing_words_module.rb', line 15

def fetch_scene(world, word_location, scene_name)
  target_scene = world.scenes[scene_name]
  unless target_scene
    raise_unknown('scene', scene_name, world.scenes.keys, word_location)
  end
  target_scene
end

#h(text) ⇒ String

HTML escape text

Parameters:

  • text (String)

Returns:

  • (String)


26
27
28
# File 'lib/tyrano_dsl/writing_words/writing_words_module.rb', line 26

def h(text)
  CGI::escapeHTML(text)
end

#raise_unknown(type, unknown_name, current_elements, word_location) ⇒ void

This method returns an undefined value.

Parameters:

  • type (String)
  • unknown_name (String)
  • current_elements (Array<String>)

Raises:



35
36
37
38
39
# File 'lib/tyrano_dsl/writing_words/writing_words_module.rb', line 35

def raise_unknown(type, unknown_name, current_elements, word_location)
  exception = TyranoDsl::TyranoException.new("Unknown #{type} [#{unknown_name}], currently #{current_elements.length} defined: #{current_elements.sort.collect {|e| "[#{e}]"}.join(', ')}")
  exception.set_backtrace word_location
  raise exception
end