Class: Point4D
- Inherits:
-
Struct
- Object
- Struct
- Point4D
- Defined in:
- lib/cem/cruzzles.rb
Instance Attribute Summary collapse
-
#w ⇒ Object
Returns the value of attribute w.
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
-
#z ⇒ Object
Returns the value of attribute z.
Instance Method Summary collapse
Instance Attribute Details
#w ⇒ Object
Returns the value of attribute w
648 649 650 |
# File 'lib/cem/cruzzles.rb', line 648 def w @w end |
#x ⇒ Object
Returns the value of attribute x
648 649 650 |
# File 'lib/cem/cruzzles.rb', line 648 def x @x end |
#y ⇒ Object
Returns the value of attribute y
648 649 650 |
# File 'lib/cem/cruzzles.rb', line 648 def y @y end |
#z ⇒ Object
Returns the value of attribute 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_s ⇒ Object
661 662 663 |
# File 'lib/cem/cruzzles.rb', line 661 def to_s "#{x}, #{y}, #{z}, #{w}" end |