Class: MLB::Transaction

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

Overview

Represents a player transaction (trade, signing, etc.)

Constant Summary collapse

TYPE_TRADE =
"TR".freeze
TYPE_FREE_AGENT =
"FA".freeze
TYPE_ASSIGNMENT =
"ASG".freeze
TYPE_SIGNING =
"SGN".freeze
TYPE_RELEASE =
"REL".freeze
TYPE_WAIVER =
"WV".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dateDate

Returns the date of the transaction

Examples:

transaction.date #=> #<Date: 2024-01-15>

Returns:

  • (Date)

    the date of the transaction



56
# File 'lib/mlb/transaction.rb', line 56

attribute :date, Shale::Type::Date

#descriptionString

Returns the full transaction description

Examples:

transaction.description #=> "Player X traded to Team Y for Player Z"

Returns:

  • (String)

    the full transaction description



96
# File 'lib/mlb/transaction.rb', line 96

attribute :description, Shale::Type::String

#effective_dateDate

Returns the effective date of the transaction

Examples:

transaction.effective_date #=> #<Date: 2024-01-16>

Returns:

  • (Date)

    the effective date of the transaction



64
# File 'lib/mlb/transaction.rb', line 64

attribute :effective_date, Shale::Type::Date

#from_teamTeam?

Returns the team the player is leaving

Examples:

transaction.from_team #=> #<MLB::Team>

Returns:

  • (Team, nil)

    the team the player is leaving



40
# File 'lib/mlb/transaction.rb', line 40

attribute :from_team, Team, default: nil

#idInteger

Returns the unique identifier for the transaction

Examples:

transaction.id #=> 12345

Returns:

  • (Integer)

    the unique identifier for the transaction



24
# File 'lib/mlb/transaction.rb', line 24

attribute :id, Shale::Type::Integer

#playerPlayer

Returns the player involved in the transaction

Examples:

transaction.player #=> #<MLB::Player>

Returns:

  • (Player)

    the player involved in the transaction



32
# File 'lib/mlb/transaction.rb', line 32

attribute :player, Player

#resolution_dateDate

Returns the resolution date of the transaction

Examples:

transaction.resolution_date #=> #<Date: 2024-01-20>

Returns:

  • (Date)

    the resolution date of the transaction



72
# File 'lib/mlb/transaction.rb', line 72

attribute :resolution_date, Shale::Type::Date

#to_teamTeam

Returns the team the player is joining

Examples:

transaction.to_team #=> #<MLB::Team>

Returns:

  • (Team)

    the team the player is joining



48
# File 'lib/mlb/transaction.rb', line 48

attribute :to_team, Team

#type_codeString

Returns the transaction type code

Examples:

transaction.type_code #=> "TR"

Returns:

  • (String)

    the transaction type code



80
# File 'lib/mlb/transaction.rb', line 80

attribute :type_code, Shale::Type::String

#type_descString

Returns the transaction type description

Examples:

transaction.type_desc #=> "Trade"

Returns:

  • (String)

    the transaction type description



88
# File 'lib/mlb/transaction.rb', line 88

attribute :type_desc, Shale::Type::String

Instance Method Details

#assignment?Boolean

Returns whether this is an assignment transaction

Examples:

transaction.assignment? #=> false

Returns:

  • (Boolean)

    whether this is an assignment



120
# File 'lib/mlb/transaction.rb', line 120

def assignment? = type_code.eql?(TYPE_ASSIGNMENT)

#free_agent?Boolean

Returns whether this is a free agent transaction

Examples:

transaction.free_agent? #=> false

Returns:

  • (Boolean)

    whether this is a free agent signing



112
# File 'lib/mlb/transaction.rb', line 112

def free_agent? = type_code.eql?(TYPE_FREE_AGENT)

#release?Boolean

Returns whether this is a release transaction

Examples:

transaction.release? #=> false

Returns:

  • (Boolean)

    whether this is a release



136
# File 'lib/mlb/transaction.rb', line 136

def release? = type_code.eql?(TYPE_RELEASE)

#signing?Boolean

Returns whether this is a signing transaction

Examples:

transaction.signing? #=> false

Returns:

  • (Boolean)

    whether this is a signing



128
# File 'lib/mlb/transaction.rb', line 128

def signing? = type_code.eql?(TYPE_SIGNING)

#trade?Boolean

Returns whether this is a trade transaction

Examples:

transaction.trade? #=> true

Returns:

  • (Boolean)

    whether this is a trade



104
# File 'lib/mlb/transaction.rb', line 104

def trade? = type_code.eql?(TYPE_TRADE)

#waiver?Boolean

Returns whether this is a waiver transaction

Examples:

transaction.waiver? #=> false

Returns:

  • (Boolean)

    whether this is a waiver



144
# File 'lib/mlb/transaction.rb', line 144

def waiver? = type_code.eql?(TYPE_WAIVER)