Permalink
Browse files

Added the Cameraplus::Page class.

  • Loading branch information...
1 parent c914b1d commit 45cd1f6b59b73bc134b6adc0cb40c09b7f3ac4ad @kevintuhumury kevintuhumury committed Mar 18, 2012
Showing with 72 additions and 0 deletions.
  1. +1 −0 lib/cameraplus.rb
  2. +18 −0 lib/cameraplus/page.rb
  3. +53 −0 spec/cameraplus/page_spec.rb
View
@@ -4,4 +4,5 @@
require "cameraplus/api/request"
require "cameraplus/api/user"
require "cameraplus/user"
+require "cameraplus/page"
require "cameraplus/version"
View
@@ -0,0 +1,18 @@
+module Cameraplus
+ class Page
+
+ attr_reader :url, :timestamp, :location, :location_name, :tweet_text, :tweet_id, :view_count, :comment_count
+
+ def initialize(data)
+ @url = data.url
+ @timestamp = data.timestamp
+ @location = data.location
+ @location_name = data.locationname
+ @tweet_text = data.tweettext
+ @tweet_id = data.tweetid
+ @view_count = data.views.to_i
+ @comment_count = data.comments.to_i
+ end
+
+ end
+end
@@ -0,0 +1,53 @@
+require 'spec_helper'
+
+describe Cameraplus::Page do
+
+ let(:data) do
+ {
+ url: "http:\/\/campl.us\/iao4",
+ tweettext: "Carnival in Venice, a travel photographer''s dream shoot!",
+ tweetid: "180064216093437954",
+ timestamp: "2012-03-14 22:53:49",
+ views: 1951,
+ comments: 1,
+ location: "45.43383498680353 12.34226474539595",
+ locationname: "Venice, Venice",
+ images: []
+ }
+ end
+
+ subject { Cameraplus::Page.new(data) }
+
+ it "has an url" do
+ subject.url.should eq "http://campl.us/iao4"
+ end
+
+ it "has a timestamp" do
+ subject.timestamp.should eq "2012-03-14 22:53:49"
+ end
+
+ it "has a location" do
+ subject.location.should eq "45.43383498680353 12.34226474539595"
+ end
+
+ it "has a location name" do
+ subject.location_name.should eq "Venice, Venice"
+ end
+
+ it "has a tweet text" do
+ subject.tweet_text.should eq "Carnival in Venice, a travel photographer''s dream shoot!"
+ end
+
+ it "has a tweet id" do
+ subject.tweet_id.should eq "180064216093437954"
+ end
+
+ it "has a view count" do
+ subject.view_count.should eq 1951
+ end
+
+ it "has a comment count" do
+ subject.comment_count.should eq 1
+ end
+
+end

0 comments on commit 45cd1f6

Please sign in to comment.