Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Extract #values

  • Loading branch information...
commit 70efecbb99dbb9ab8375f74291a514e0eef56899 1 parent 3571ce4
Tom Stuart tomstuart authored
Showing with 11 additions and 1 deletion.
  1. +5 −1 lib/values.rb
  2. +6 −0 spec/values_spec.rb
6 lib/values.rb
View
@@ -29,7 +29,7 @@ def ==(other)
def eql?(other)
return false if other.class != self.class
- self.class::VALUE_ATTRS.map { |field| send(field) } == self.class::VALUE_ATTRS.map { |field| other.send(field) }
+ values == other.values
end
def hash
@@ -39,6 +39,10 @@ def hash
end
return result + self.class.hash
end
+
+ def values
+ self.class::VALUE_ATTRS.map { |field| send(field) }
+ end
end
end
end
6 spec/values_spec.rb
View
@@ -107,4 +107,10 @@ def change_color(new_color)
Point.new(0,0).hash.should_not == Y.new(0,0).hash
end
end
+
+ describe '#values' do
+ it 'returns an array of field values' do
+ Point.new(10, 13).values.should == [10, 13]
+ end
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.