Sha256: 935e7ec861ddf2c2bc4534a35dc2515b2f126c28321396aa932471c2a2b15042
Contents?: true
Size: 717 Bytes
Versions: 5
Compression:
Stored size: 717 Bytes
Contents
# # Generic Point/Size unit # class UnderOs::Point def initialize(x, y=nil) if x.is_a?(UnderOs::Point) y = x.y if x.y x = x.x elsif x.is_a?(Hash) y = x[:y] || x['y'] || nil x = x[:x] || x['x'] || nil end @x = x @y = y end def x @x end def y @y end def ==(*args) point = UnderOs::Point.new(*args) # normalizing x == point.x && y == point.y end def *(multiplier) self.class.new(x: @x * multiplier, y: @y * multiplier) end def /(divider) self.class.new(x: @x / divider.to_f, y: @y / divider.to_f) end def to_s "x=#{x} y=#{y}" end def inspect "#<#{self.class.name}:0x#{__id__.to_s(16)} #{to_s}>" end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
under-os-1.3.0 | lib/under_os/point.rb |
under-os-1.2.1 | lib/under_os/point.rb |
under-os-1.2.0 | lib/under_os/point.rb |
under-os-1.1.0 | lib/under_os/point.rb |
under-os-1.0.0 | lib/under_os/point.rb |