Sha256: 43d69917a0d32688480e041dac9435f9239cdb7cf4d45fc86e55daadbcc9c3e8
Contents?: true
Size: 1.2 KB
Versions: 3
Compression:
Stored size: 1.2 KB
Contents
module Vedeu class Geometry def initialize(values = {}) @values = values || {} end def origin(index = 0) Position.set(vy(index), vx) end def y values[:y] end alias_method :row, :y alias_method :line, :y def x values[:x] end alias_method :column, :x alias_method :col, :x def width values[:width] end def height values[:height] end def dy clip_y? ? defaults[:height] : (y + height) end def dx clip_x? ? defaults[:width] : (x + width) end def vx(index = 0) # virtual x position ((x..dx).to_a)[index] end def vy(index = 0) # virtual y position ((y..dy).to_a)[index] end private def clip_y? ((y + height) > defaults[:height]) end def clip_x? ((x + width) > defaults[:width]) end def values defaults.merge!(auto) end def auto @values.delete_if { |k, v| k == :width && v == :auto } @values.delete_if { |k, v| k == :height && v == :auto } end def defaults { width: Terminal.width, height: Terminal.height, y: 1, x: 1 } end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
vedeu-0.0.24 | lib/vedeu/output/geometry.rb |
vedeu-0.0.23 | lib/vedeu/output/geometry.rb |
vedeu-0.0.22 | lib/vedeu/output/geometry.rb |