Class: Point4D

Inherits:
Struct
  • Object
show all
Defined in:
lib/cem/cruzzles.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#wObject

Returns the value of attribute w

Returns:

  • (Object)

    the current value of w



648
649
650
# File 'lib/cem/cruzzles.rb', line 648

def w
  @w
end

#xObject

Returns the value of attribute x

Returns:

  • (Object)

    the current value of x



648
649
650
# File 'lib/cem/cruzzles.rb', line 648

def x
  @x
end

#yObject

Returns the value of attribute y

Returns:

  • (Object)

    the current value of y



648
649
650
# File 'lib/cem/cruzzles.rb', line 648

def y
  @y
end

#zObject

Returns the value of attribute z

Returns:

  • (Object)

    the current value of z



648
649
650
# File 'lib/cem/cruzzles.rb', line 648

def z
  @z
end

Instance Method Details

#-(other) ⇒ Object



657
658
659
# File 'lib/cem/cruzzles.rb', line 657

def -(other)
  Point4D.new(x - other.x, y - other.y, z - other.z, w - other.w)
end

#manhattan(other = nil) ⇒ Object



650
651
652
653
654
655
# File 'lib/cem/cruzzles.rb', line 650

def manhattan(other=nil)
  if other != nil
    return (self - other).manhattan
  end
  return x.abs + y.abs + z.abs + w.abs
end

#to_sObject



661
662
663
# File 'lib/cem/cruzzles.rb', line 661

def to_s
  "#{x}, #{y}, #{z}, #{w}"
end