Class: UI::Point

Inherits:
Object
  • Object
show all
Defined in:
lib/ektoplayer/ui.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x: 0, y: 0) ⇒ Point

Returns a new instance of Point.



211
212
213
# File 'lib/ektoplayer/ui.rb', line 211

def initialize(x: 0, y: 0)
   @x, @y = x, y
end

Instance Attribute Details

#xObject

Returns the value of attribute x.



209
210
211
# File 'lib/ektoplayer/ui.rb', line 209

def x
  @x
end

#yObject

Returns the value of attribute y.



209
210
211
# File 'lib/ektoplayer/ui.rb', line 209

def y
  @y
end

Instance Method Details

#<=(p) ⇒ Object



224
# File 'lib/ektoplayer/ui.rb', line 224

def <=(p)  @x <= p.x and @y <= p.y     end

#==(p) ⇒ Object



225
# File 'lib/ektoplayer/ui.rb', line 225

def ==(p)  @x == p.x and @y == p.y     end

#>=(p) ⇒ Object



223
# File 'lib/ektoplayer/ui.rb', line 223

def >=(p)  @x >= p.x and @y >= p.y     end

#calc(x: 0, y: 0) ⇒ Object



219
220
221
# File 'lib/ektoplayer/ui.rb', line 219

def calc(x: 0, y: 0)
   Point.new(x: @x + x, y: @y + y)
end

#to_sObject



226
# File 'lib/ektoplayer/ui.rb', line 226

def to_s;  "[(Point) x=#{x}, y=#{y}]"  end

#update(x: nil, y: nil) ⇒ Object



215
216
217
# File 'lib/ektoplayer/ui.rb', line 215

def update(x: nil, y: nil)
   Point.new(x: (x or @x), y: (y or @y))
end