Class: MLB::Position

Inherits:
Shale::Mapper
  • Object
show all
Defined in:
lib/mlb/position.rb

Overview

Represents a baseball position

Constant Summary collapse

TYPE_PITCHER =
"Pitcher".freeze
TYPE_CATCHER =
"Catcher".freeze
TYPE_INFIELDER =
"Infielder".freeze
TYPE_OUTFIELDER =
"Outfielder".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#abbreviationString

Returns the position abbreviation

Examples:

position.abbreviation #=> "P"

Returns:

  • (String)

    the position abbreviation



44
# File 'lib/mlb/position.rb', line 44

attribute :abbreviation, Shale::Type::String

#codeString

Returns the position code

Examples:

position.code #=> "1"

Returns:

  • (String)

    the position code



20
# File 'lib/mlb/position.rb', line 20

attribute :code, Shale::Type::String

#nameString

Returns the position name

Examples:

position.name #=> "Pitcher"

Returns:

  • (String)

    the position name



28
# File 'lib/mlb/position.rb', line 28

attribute :name, Shale::Type::String

#typeString

Returns the position type

Examples:

position.type #=> "Pitcher"

Returns:

  • (String)

    the position type



36
# File 'lib/mlb/position.rb', line 36

attribute :type, Shale::Type::String

Instance Method Details

#catcher?Boolean

Returns whether this is a catcher position

Examples:

position.catcher? #=> false

Returns:

  • (Boolean)

    whether this is a catcher



60
# File 'lib/mlb/position.rb', line 60

def catcher? = type.eql?(TYPE_CATCHER)

#infielder?Boolean

Returns whether this is an infielder position

Examples:

position.infielder? #=> false

Returns:

  • (Boolean)

    whether this is an infielder



68
# File 'lib/mlb/position.rb', line 68

def infielder? = type.eql?(TYPE_INFIELDER)

#outfielder?Boolean

Returns whether this is an outfielder position

Examples:

position.outfielder? #=> false

Returns:

  • (Boolean)

    whether this is an outfielder



76
# File 'lib/mlb/position.rb', line 76

def outfielder? = type.eql?(TYPE_OUTFIELDER)

#pitcher?Boolean

Returns whether this is a pitcher position

Examples:

position.pitcher? #=> true

Returns:

  • (Boolean)

    whether this is a pitcher



52
# File 'lib/mlb/position.rb', line 52

def pitcher? = type.eql?(TYPE_PITCHER)