Class: SecretSharing::Point
 Inherits:

Object
 Object
 SecretSharing::Point
 Defined in:
 lib/secret_sharing/point.rb
Overview
This class is used to store a two dimensional point consisting of integers.
Instance Attribute Summary collapse

#x ⇒ Integer
readonly
X value the point was instantiated with.

#y ⇒ Integer
readonly
Y value the point was instantiated with.
Class Method Summary collapse

.transpose(points) ⇒ Array
An implementation similar to Array#transpose for Arrays of Points.
Instance Method Summary collapse

#initialize(x, y) ⇒ Point
constructor
Create a Point object.
Constructor Details
Instance Attribute Details
#x ⇒ Integer (readonly)
Returns x value the point was instantiated with
5 6 7 
# File 'lib/secret_sharing/point.rb', line 5 def x @x end 
#y ⇒ Integer (readonly)
Returns y value the point was instantiated with
7 8 9 
# File 'lib/secret_sharing/point.rb', line 7 def y @y end 
Class Method Details
.transpose(points) ⇒ Array
An implementation similar to Array#transpose for Arrays of Points
Examples
point1 = SecretSharing::Point.new(1, 2)
point2 = SecretSharing::Point.new(3, 4)
points = [point1, point2]
Point.transpose(points)
# => [[1, 3], [2, 4]]
34 35 36 37 38 39 40 41 42 43 
# File 'lib/secret_sharing/point.rb', line 34 def self.transpose(points) x_values = [] y_values = [] points.each do point x_values << point.x y_values << point.y end [x_values, y_values] end 