Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 96cf4b7563
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 22 lines (17 sloc) 0.463 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
class Jersey < String
  def initialize(object)
    super "Jersey Number #{object})"
  end
end

class BaseballPlayer < Valuable

  has_value :at_bats, :klass => Integer
  has_value :hits, :klass => Integer
  has_value :league, :default => 'unknown'
  has_value :name
  has_value :jersey, :klass => Jersey, :default => 'Unknown'
  has_value :active, :klass => Boolean
  
  has_collection :teammates

  def average
    hits/at_bats.to_f if hits && at_bats
  end
end
Something went wrong with that request. Please try again.