class McBlocky::Rect
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
# File lib/mcblocky/location.rb, line 47 def initialize(*args) if args.length == 6 super elsif args.length == 2 super(args[0].x, args[0].y, args[0].z, args[1].x, args[1].y, args[1].z) elsif args.length == 4 if args[0].respond_to? :x super(args[0].x, args[0].y, args[0].z, args[1], args[2], args[3]) elsif args[3].respond_to? :x super(args[0], args[1], args[2], args[3].x, args[3].y, args[3].z) else raise ArgumentError end else raise ArgumentError end if x1 > x2 self.x1, self.x2 = self.x2, self.x1 end if y1 > y2 self.y1, self.y2 = self.y2, self.y1 end if z1 > z2 self.z1, self.z2 = self.z2, self.z1 end end
Public Instance Methods
d()
click to toggle source
# File lib/mcblocky/location.rb, line 91 def d z2 - z1 end
h()
click to toggle source
# File lib/mcblocky/location.rb, line 87 def h y2 - y1 end
p1()
click to toggle source
# File lib/mcblocky/location.rb, line 75 def p1 @p1 ||= Location.new(x1, y1, z1) end
p2()
click to toggle source
# File lib/mcblocky/location.rb, line 79 def p2 @p2 ||= Location.new(x2, y2, z2) end
w()
click to toggle source
# File lib/mcblocky/location.rb, line 83 def w x2 - x1 end