Sha256: 2196a51cb5069bb7651d3d9c42dd776442b2519fca2645a34f0cb0cfc656e641

Contents?: true

Size: 626 Bytes

Versions: 1

Compression:

Stored size: 626 Bytes

Contents

module Luck
class Control
  attr_accessor :pane, :display, :x1, :y1, :x2, :y2
  
  def initialize pane, x1, y1, x2, y2, &blck
    @pane = pane
    @display = pane.display
    @x1, @y1 = x1, y1
    @x2, @y2 = x2, y2
    
    instance_eval &blck if blck
  end
  
  def x1
    @pane.x1 + ((@x1 < 0) ? (@pane.width + @x1) : @x1)
  end
  def y1
    @pane.y1 + ((@y1 < 0) ? (@pane.height + @y1) : @y1)
  end
  
  def x2
    @pane.x1 + ((@x2 < 0) ? (@pane.width + @x2 + 1) : @x2)
  end
  def y2
    @pane.y1 + ((@y2 < 0) ? (@pane.height + @y2 + 1) : @y2)
  end
  
  def width
    x2 - x1
  end
  def height
    y2 - y1
  end
end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
luck-0.0.0 lib/luck/control.rb