Module: Languages::Generic::Position

Included in:
Epl2::Position, Zpl2::Position
Defined in:
lib/languages/generic/position.rb

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#xObject

Returns the value of attribute x.



25
26
27
# File 'lib/languages/generic/position.rb', line 25

def x
  @x
end

#yObject

Returns the value of attribute y.



25
26
27
# File 'lib/languages/generic/position.rb', line 25

def y
  @y
end

Class Method Details

.included(base) ⇒ Object



4
5
6
# File 'lib/languages/generic/position.rb', line 4

def self.included(base)
  base.extend ClassMethods
end

Instance Method Details

#+(v) ⇒ Object



28
29
30
31
32
33
# File 'lib/languages/generic/position.rb', line 28

def +(v)
  case v
  when Position
    self.class[x+v.x,y+v.y]
  end
end

#==(v) ⇒ Object



35
36
37
# File 'lib/languages/generic/position.rb', line 35

def ==(v)
  (x==v.x) && (y==v.y)
end

#to_aObject



55
56
57
# File 'lib/languages/generic/position.rb', line 55

def to_a
  [x,y]
end

#to_sObject



59
60
61
# File 'lib/languages/generic/position.rb', line 59

def to_s
  "#{x.to_dots},#{y.to_dots}"
end