Class: McBlocky::Location

Inherits:
Struct
  • Object
show all
Defined in:
lib/mcblocky/location.rb

Direct Known Subclasses

RelativeLocation

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#xObject

Returns the value of attribute x

Returns:

  • (Object)

    the current value of x



2
3
4
# File 'lib/mcblocky/location.rb', line 2

def x
  @x
end

#yObject

Returns the value of attribute y

Returns:

  • (Object)

    the current value of y



2
3
4
# File 'lib/mcblocky/location.rb', line 2

def y
  @y
end

#zObject

Returns the value of attribute z

Returns:

  • (Object)

    the current value of z



2
3
4
# File 'lib/mcblocky/location.rb', line 2

def z
  @z
end

Instance Method Details

#+(other) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/mcblocky/location.rb', line 3

def +(other)
  if other.is_relative?
    Location.new(x + other.x, y + other.y, z + other.z)
  else
    RelativeLocation.new(x + other.x, y + other.y, z + other.z)
  end
end

#-(other) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/mcblocky/location.rb', line 11

def -(other)
  if other.is_relative?
    Location.new(x - other.x, y - other.y, z - other.z)
  else
    RelativeLocation.new(x - other.x, y - other.y, z - other.z)
  end
end

#is_relative?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/mcblocky/location.rb', line 19

def is_relative?
  false
end