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>


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"


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>


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>


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


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>


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>


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>


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

attribute :to_team, Team

#type_codeString

Returns the transaction type code

Examples:

transaction.type_code #=> "TR"


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"


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


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


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


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


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


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


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

def waiver? = type_code.eql?(TYPE_WAIVER)