Class: Gobstones::Lang::Commands::RepeatWith
- Inherits:
-
Object
- Object
- Gobstones::Lang::Commands::RepeatWith
- Includes:
- EqualityDefinition
- Defined in:
- lib/gobstones/lang/commands/repeat_with.rb
Instance Attribute Summary collapse
-
#cmd_block ⇒ Object
readonly
Returns the value of attribute cmd_block.
-
#range_max ⇒ Object
readonly
Returns the value of attribute range_max.
-
#range_min ⇒ Object
readonly
Returns the value of attribute range_min.
-
#var_name ⇒ Object
readonly
Returns the value of attribute var_name.
Instance Method Summary collapse
- #equality_attributes ⇒ Object
- #evaluate(context) ⇒ Object
-
#initialize(var_name, range_min, range_max, cmd_block) ⇒ RepeatWith
constructor
A new instance of RepeatWith.
Methods included from EqualityDefinition
Constructor Details
#initialize(var_name, range_min, range_max, cmd_block) ⇒ RepeatWith
18 19 20 21 22 23 |
# File 'lib/gobstones/lang/commands/repeat_with.rb', line 18 def initialize(var_name, range_min, range_max, cmd_block) @var_name = var_name @range_min = range_min @range_max = range_max @cmd_block = cmd_block end |
Instance Attribute Details
#cmd_block ⇒ Object (readonly)
Returns the value of attribute cmd_block.
16 17 18 |
# File 'lib/gobstones/lang/commands/repeat_with.rb', line 16 def cmd_block @cmd_block end |
#range_max ⇒ Object (readonly)
Returns the value of attribute range_max.
16 17 18 |
# File 'lib/gobstones/lang/commands/repeat_with.rb', line 16 def range_max @range_max end |
#range_min ⇒ Object (readonly)
Returns the value of attribute range_min.
16 17 18 |
# File 'lib/gobstones/lang/commands/repeat_with.rb', line 16 def range_min @range_min end |
#var_name ⇒ Object (readonly)
Returns the value of attribute var_name.
16 17 18 |
# File 'lib/gobstones/lang/commands/repeat_with.rb', line 16 def var_name @var_name end |
Instance Method Details
#equality_attributes ⇒ Object
25 26 27 |
# File 'lib/gobstones/lang/commands/repeat_with.rb', line 25 def equality_attributes %i[var_name range_min range_max cmd_block] end |
#evaluate(context) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/gobstones/lang/commands/repeat_with.rb', line 29 def evaluate(context) validate_range_values context validate_index_variable_not_defined context while_based_equivalent_cmd.evaluate context clear_index_variable_from context end |