Sha256: cd8c6677a246f0135a5b78cb349bc0f8dace111312a20a899adaf3351c497c36
Contents?: true
Size: 689 Bytes
Versions: 1
Compression:
Stored size: 689 Bytes
Contents
module Triangular class Point attr_accessor :x, :y, :z def initialize(x, y, z) @x = x @y = y @z = z end def to_s "#{@x.to_f} #{@y.to_f} #{@z.to_f}" end def ==(other) return false unless other.is_a?(Point) self.x == other.x && self.y == other.y && self.z == other.z end def self.parse(string) string.strip! match_data = string.match(self.pattern) self.new(match_data[:x].to_f, match_data[:y].to_f, match_data[:z].to_f) end def self.pattern /(?<x>-?\d+.\d+(e\-?\d+)?)\s(?<y>-?\d+.\d+(e\-?\d+)?)\s(?<z>-?\d+.\d+(e\-?\d+)?)/ end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
triangular-0.0.1 | lib/triangular/point.rb |