Skip to content

Commit

Permalink
Added Coach class
Browse files Browse the repository at this point in the history
  • Loading branch information
ignu committed Aug 16, 2014
1 parent caf5a6b commit c2f452f
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 1 deletion.
1 change: 1 addition & 0 deletions .bacon
@@ -0,0 +1 @@
--color
1 change: 1 addition & 0 deletions Gemfile
@@ -1,4 +1,5 @@
source 'https://rubygems.org'

gem 'rake'
gem 'motion-redgreen'
# Add your dependencies here:
12 changes: 12 additions & 0 deletions Gemfile.lock
@@ -0,0 +1,12 @@
GEM
remote: https://rubygems.org/
specs:
motion-redgreen (0.1.0)
rake (10.3.2)

PLATFORMS
ruby

DEPENDENCIES
motion-redgreen
rake
1 change: 1 addition & 0 deletions Rakefile
Expand Up @@ -11,4 +11,5 @@ end
Motion::Project::App.setup do |app|
# Use `rake config' to see complete project settings.
app.name = 'tymur'
app.redgreen_style = :full
end
7 changes: 6 additions & 1 deletion app/app_delegate.rb
@@ -1,5 +1,10 @@
class AppDelegate
def application(application, didFinishLaunchingWithOptions:launchOptions)
true
vc = TimerController.new

@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
@window.rootViewController = vc
@window.rootViewController.wantsFullScreenLayout = true
@window.makeKeyAndVisible
end
end
14 changes: 14 additions & 0 deletions app/coach.rb
@@ -0,0 +1,14 @@
class Coach
attr_accessor :rounds_count

def initialize
self.rounds_count = 0
end

def average
end

def record_round
self.rounds_count = self.rounds_count + 1
end
end
10 changes: 10 additions & 0 deletions app/timer_controller.rb
@@ -0,0 +1,10 @@
class TimerController < UIViewController
def loadView
self.view = TimerView.new
end

def viewDidLoad
view.backgroundColor = UIColor.whiteColor
super
end
end
19 changes: 19 additions & 0 deletions app/timer_view.rb
@@ -0,0 +1,19 @@
class TimerView < UIView
attr_accessor :counter_label

def drawRect(rect)
super rect
create_counter_label
end

def create_counter_label
counter_label = UILabel.new
counter_label.text = "0"
counter_label.frame = self.frame
counter_label.adjustsFontSizeToFitWidth = true
counter_label.font = UIFont.fontWithName("Arial", size:64)


self.addSubview(counter_label)
end
end
25 changes: 25 additions & 0 deletions spec/coach_spec.rb
@@ -0,0 +1,25 @@
describe "Coach" do
before do
@coach = Coach.new
end

context "with zero rounds" do
it "does not have an average" do
@coach.average.should == nil
end

it "has zero rounds" do
@coach.average.should == nil
end
end

describe "record_round" do
before do
@coach.record_round
end

it "increments the count" do
@coach.rounds_count.should == 1
end
end
end

0 comments on commit c2f452f

Please sign in to comment.