Sha256: 34b2e9f639909d2d156a83ec09ea6e4e82f70570e462d8cc216b41796e9f4642

Contents?: true

Size: 388 Bytes

Versions: 9

Compression:

Stored size: 388 Bytes

Contents

module FootballManager
  class Player

    attr_accessor :name, :skill

    def initialize(name, skill)
      @name = name if valid?(name, 'name')
      @skill = skill.to_i if valid?(skill, 'skill')
    end

    def valid?(attribute, attribute_name)
      attribute.nil? ? fail(FootballManager::PlayerError, "You cannot create a player with no #{attribute_name}") : true
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
football-manager-1.0.1 lib/football-manager/player.rb
football-manager-0.1.8 lib/football-manager/player.rb
football-manager-0.1.7 lib/football-manager/player.rb
football-manager-0.1.6 lib/football-manager/player.rb
football-manager-0.1.5 lib/football-manager/player.rb
football-manager-0.1.4 lib/football-manager/player.rb
football-manager-0.1.2 lib/football-manager/player.rb
football-manager-0.1.1 lib/football-manager/player.rb
football-manager-0.1.0 lib/football-manager/player.rb