Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #277.
- Loading branch information
Showing
29 changed files
with
473 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
require 'twitter/base' | ||
|
||
module Twitter | ||
class Geo < Twitter::Base | ||
attr_reader :coordinates | ||
alias coords coordinates | ||
|
||
# @param other [Twitter::Geo] | ||
# @return [Boolean] | ||
def ==(other) | ||
super || self.coordinates_equal(other) || self.attrs_equal(other) | ||
end | ||
|
||
protected | ||
|
||
# @param other [Twitter::Geo] | ||
# @return [Boolean] | ||
def coordinates_equal(other) | ||
self.class == other.class && !other.coordinates.nil? && self.coordinates == other.coordinates | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
require 'twitter/geo' | ||
|
||
module Twitter | ||
class Point < Twitter::Geo | ||
|
||
# @return [Integer] | ||
def latitude | ||
self.coordinates[0] | ||
end | ||
alias lat latitude | ||
|
||
# @return [Integer] | ||
def longitude | ||
self.coordinates[1] | ||
end | ||
alias long longitude | ||
alias lng longitude | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
require 'twitter/geo' | ||
|
||
module Twitter | ||
class Polygon < Twitter::Geo | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require 'helper' | ||
|
||
describe Twitter::Geo do | ||
|
||
before do | ||
@geo = Twitter::Geo.new(:coordinates => [[[-122.40348192, 37.77752898], [-122.387436, 37.77752898], [-122.387436, 37.79448597], [-122.40348192, 37.79448597]]]) | ||
end | ||
|
||
describe "#==" do | ||
it "returns false for empty objects" do | ||
geo = Twitter::Geo.new | ||
other = Twitter::Geo.new | ||
(geo == other).should be_false | ||
end | ||
it "returns true when objects coordinates are the same" do | ||
other = Twitter::Geo.new(:coordinates => [[[-122.40348192, 37.77752898], [-122.387436, 37.77752898], [-122.387436, 37.79448597], [-122.40348192, 37.79448597]]]) | ||
(@geo == other).should be_true | ||
end | ||
it "returns false when objects coordinates are different" do | ||
other = Twitter::Geo.new(:coordinates => [[[37.77752898, -122.40348192], [37.77752898, -122.387436], [37.79448597, -122.387436], [37.79448597, -122.40348192]]]) | ||
(@geo == other).should be_false | ||
end | ||
it "returns false when classes are different" do | ||
other = Twitter::Polygon.new(:coordinates => [[[-122.40348192, 37.77752898], [-122.387436, 37.77752898], [-122.387436, 37.79448597], [-122.40348192, 37.79448597]]]) | ||
(@geo == other).should be_false | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
require 'helper' | ||
|
||
describe Twitter::Identifiable do | ||
|
||
describe "#==" do | ||
it "returns false for empty objects" do | ||
one = Twitter::Identifiable.new | ||
two = Twitter::Identifiable.new | ||
(one == two).should be_false | ||
end | ||
it "returns true when objects IDs are the same" do | ||
one = Twitter::Identifiable.new(:id => 1, :screen_name => "sferik") | ||
two = Twitter::Identifiable.new(:id => 1, :screen_name => "garybernhardt") | ||
(one == two).should be_true | ||
end | ||
it "returns false when objects IDs are different" do | ||
one = Twitter::Identifiable.new(:id => 1) | ||
two = Twitter::Identifiable.new(:id => 2) | ||
(one == two).should be_false | ||
end | ||
it "returns false when classes are different" do | ||
one = Twitter::Identifiable.new(:id => 1) | ||
two = Twitter::Base.new(:id => 1) | ||
(one == two).should be_false | ||
end | ||
it "returns true when objects non-ID attributes are the same" do | ||
one = Twitter::Identifiable.new(:screen_name => "sferik") | ||
two = Twitter::Identifiable.new(:screen_name => "sferik") | ||
(one == two).should be_true | ||
end | ||
it "returns false when objects non-ID attributes are different" do | ||
one = Twitter::Identifiable.new(:screen_name => "sferik") | ||
two = Twitter::Identifiable.new(:screen_name => "garybernhardt") | ||
(one == two).should be_false | ||
end | ||
end | ||
|
||
end |
Oops, something went wrong.