Permalink
Browse files

Added the Cameraplus::Photo class.

  • Loading branch information...
1 parent b9bb13d commit cc3e1ed560fb8919c54cbc5387575d73275cf7d8 @kevintuhumury kevintuhumury committed Mar 19, 2012
Showing with 59 additions and 0 deletions.
  1. +1 −0 lib/cameraplus.rb
  2. +16 −0 lib/cameraplus/photo.rb
  3. +42 −0 spec/cameraplus/photo_spec.rb
View
@@ -5,4 +5,5 @@
require "cameraplus/api/user"
require "cameraplus/user"
require "cameraplus/page"
+require "cameraplus/photo"
require "cameraplus/version"
View
@@ -0,0 +1,16 @@
+module Cameraplus
+ class Photo
+
+ attr_reader :small, :medium, :large, :width, :height, :location
+
+ def initialize(data)
+ @small = data["120px"]
+ @medium = data["480px"]
+ @large = data["800px"]
+ @width = data.fullwidth.to_i
+ @height = data.fullheight.to_i
+ @location = data.location
+ end
+
+ end
+end
@@ -0,0 +1,42 @@
+require 'spec_helper'
+
+describe Cameraplus::Photo do
+
+ let(:data) do
+ {
+ "800px" => "http:\/\/pics.campl.us\/f\/0\/0b497f01791c851db1a17f81e0621a5c.jpg",
+ "120px" => "http:\/\/pics.campl.us\/t\/0\/0b497f01791c851db1a17f81e0621a5c.jpg",
+ "480px" => "http:\/\/pics.campl.us\/iphone\/0\/0b497f01791c851db1a17f81e0621a5c.jpg",
+ :fullwidth => 800,
+ :fullheight => 590,
+ :location => "45.43383498680353 12.34226474539595"
+ }
+ end
+
+ subject { Cameraplus::Photo.new(data) }
+
+ it "has a small version" do
+ subject.small.should eq "http://pics.campl.us/t/0/0b497f01791c851db1a17f81e0621a5c.jpg"
+ end
+
+ it "has a medium version" do
+ subject.medium.should eq "http://pics.campl.us/iphone/0/0b497f01791c851db1a17f81e0621a5c.jpg"
+ end
+
+ it "has a large version" do
+ subject.large.should eq "http://pics.campl.us/f/0/0b497f01791c851db1a17f81e0621a5c.jpg"
+ end
+
+ it "has a width" do
+ subject.width.should eq 800
+ end
+
+ it "has a height" do
+ subject.height.should eq 590
+ end
+
+ it "has a location" do
+ subject.location.should eq "45.43383498680353 12.34226474539595"
+ end
+
+end

0 comments on commit cc3e1ed

Please sign in to comment.