Class: Gobstones::Lang::Commands::RepeatWith

Inherits:
Object
  • Object
show all
Includes:
EqualityDefinition
Defined in:
lib/gobstones/lang/commands/repeat_with.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_blockObject (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_maxObject (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_minObject (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_nameObject (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_attributesObject



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