Class: RubyLabs::TSPLab::ItemWithDirection

Inherits:
Struct
  • Object
show all
Defined in:
lib/tsplab.rb,
lib/tsplab.rb

Overview

An ItemWithDirection is a struct with two fields, a numeric value and a character that represents right or left, used by the Johnson-Trotter algorithm that generates permutations of points on a map.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#directionObject

Returns the value of attribute direction

Returns:

  • (Object)

    the current value of direction



23
24
25
# File 'lib/tsplab.rb', line 23

def direction
  @direction
end

#valueObject

Returns the value of attribute value

Returns:

  • (Object)

    the current value of value



23
24
25
# File 'lib/tsplab.rb', line 23

def value
  @value
end

Instance Method Details

#inspectObject

:nodoc:



30
31
32
# File 'lib/tsplab.rb', line 30

def inspect   # :nodoc:
  (self.direction ? "<" : ">") + self.value.inspect
end