Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

extract url building out into a new object

  • Loading branch information...
commit 2068a604ba0e394f83b51d64a7b7dd8c58f31b87 1 parent bb56dc2
@pzimbelman authored
View
1  lib/twithub.rb
@@ -8,6 +8,7 @@
require_relative 'twithub/twitter_entry'
require_relative 'twithub/github_entry'
require_relative 'twithub/entries'
+require_relative 'twithub/twitter_status_url'
module Twithub
TWITTER = "twitter"
View
4 lib/twithub/twitter.rb
@@ -3,8 +3,8 @@ class Twitter
def self.entries_for(username)
return [] unless username
::Twitter.user_timeline(username).map do |status|
- url = "http://twitter.com/#{status.from_user}/status/#{status.id}"
- TwitterEntry.new.with_content(status.text).with_username(status.from_user).with_posted_at(status.created_at).with_url(url)
+ url = Twithub::TwitterStatusUrl.new(status.id, status.from_user)
+ TwitterEntry.new.with_content(status.text).with_username(status.from_user).with_posted_at(status.created_at).with_url(url.to_s)
end
end
end
View
12 lib/twithub/twitter_status_url.rb
@@ -0,0 +1,12 @@
+module Twithub
+ class TwitterStatusUrl
+ def initialize(id, username)
+ @id = id
+ @username = username
+ end
+
+ def to_s
+ "http://twitter.com/#{@username}/status/#{@id}"
+ end
+ end
+end
View
7 spec/twithub/twitter_status_url_spec.rb
@@ -0,0 +1,7 @@
+require_relative '../../lib/twithub'
+
+describe Twithub::TwitterStatusUrl do
+ it "should build a url of the correct format" do
+ Twithub::TwitterStatusUrl.new(12, "theuser").to_s.should == "http://twitter.com/theuser/status/12"
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.