Sha256: 054fbe6b739e1ad91cb840d2095955e7722ab24d5a69eef001fc1152927b6aea

Contents?: true

Size: 463 Bytes

Versions: 15

Compression:

Stored size: 463 Bytes

Contents

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

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
valuable-0.9.14 examples/baseball.rb
valuable-0.9.13 examples/baseball.rb
valuable-0.9.12 examples/baseball.rb
valuable-0.9.11 examples/baseball.rb
valuable-0.9.10 examples/baseball.rb
valuable-0.9.9 examples/baseball.rb
valuable-0.9.8 examples/baseball.rb
valuable-0.9.7 examples/baseball.rb
valuable-0.9.6 examples/baseball.rb
valuable-0.9.5 examples/baseball.rb
valuable-0.9.4 examples/baseball.rb
valuable-0.9.3 examples/baseball.rb
valuable-0.9.2 examples/baseball.rb
valuable-0.9.1 examples/baseball.rb
valuable-0.9.0 examples/baseball.rb