Module: TyranoDsl::ParsingWords::DeclareVariable
- Includes:
- ParsingWordsModule
- Defined in:
- lib/tyrano_dsl/parsing_words/declare_variable.rb
Instance Method Summary collapse
Instance Method Details
#declare_variable(variable_name, initial_value) ⇒ void
This method returns an undefined value.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/tyrano_dsl/parsing_words/declare_variable.rb', line 13 def declare_variable(variable_name, initial_value) if context.world.variables.key? variable_name raise TyranoDsl::TyranoException, "Duplicated variable [#{variable_name}]" else context.world.variables[variable_name] = TyranoDsl::Elements::Variable.new( variable_name, "variable_#{context.world.variables.length + 1}", initial_value ) end add_parsed_word( TyranoDsl::Vocabulary::DECLARE_VARIABLE, variable_name: variable_name, initial_value: initial_value, ) end |