Sha256: d5bc37756f4fef28f01efa7649a2efa2f5db528c34e2b1b7f928bafac1ab1243
Contents?: true
Size: 476 Bytes
Versions: 22
Compression:
Stored size: 476 Bytes
Contents
module Bulldog class Vector2 def initialize(object) case object when Array @x, @y = object[0].to_i, object[1].to_i when String match = /([+-]?\d+)[^-+\d]*([+-]?\d+)/.match(object) or raise ArgumentError, "invalid vector: #{object.inspect}" @x, @y = match[1].to_i, match[2].to_i else raise ArgumentError, "cannot convert to vector: #{object.inspect}" end end attr_accessor :x, :y end end
Version data entries
22 entries across 22 versions & 1 rubygems