Class: MLB::Jobs

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

Overview

Provides methods for fetching job data from the API

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#rosterArray<Job>

Returns the job roster

Examples:

jobs.roster #=> [#<MLB::Job>, ...]

Returns:

  • (Array<Job>)

    the job roster



13
# File 'lib/mlb/jobs.rb', line 13

attribute :roster, Job, collection: true

Class Method Details

.datacasters(season: nil) ⇒ Array<Job>

Retrieves all datacasters

Examples:

Get all datacasters for the current season

MLB::Jobs.datacasters

Get datacasters for a specific season

MLB::Jobs.datacasters(season: 2024)

Parameters:

  • season (Integer, nil) (defaults to: nil)

    the season year (defaults to current year)

Returns:

  • (Array<Job>)

    the datacasters



41
42
43
# File 'lib/mlb/jobs.rb', line 41

def self.datacasters(season: nil)
  fetch_jobs("jobs/datacasters", season:)
end

.official_scorers(season: nil) ⇒ Array<Job>

Retrieves all official scorers

Examples:

Get all official scorers for the current season

MLB::Jobs.official_scorers

Get official scorers for a specific season

MLB::Jobs.official_scorers(season: 2024)

Parameters:

  • season (Integer, nil) (defaults to: nil)

    the season year (defaults to current year)

Returns:

  • (Array<Job>)

    the official scorers



54
55
56
# File 'lib/mlb/jobs.rb', line 54

def self.official_scorers(season: nil)
  fetch_jobs("jobs/officialScorers", season:)
end

.umpire_games(umpire:, season: nil) ⇒ Array<Job>

Retrieves games for a specific umpire

Examples:

Get games for an umpire

MLB::Jobs.umpire_games(umpire: 427127, season: 2024)

Parameters:

  • umpire (Job, Integer)

    the umpire or umpire ID

  • season (Integer, nil) (defaults to: nil)

    the season year (defaults to current year)

Returns:

  • (Array<Job>)

    the umpire’s game assignments



66
67
68
69
# File 'lib/mlb/jobs.rb', line 66

def self.umpire_games(umpire:, season: nil)
  umpire_id = umpire.respond_to?(:person) ? umpire.person.id : umpire
  fetch_jobs("jobs/umpires/games/#{umpire_id}", season:)
end

.umpires(season: nil) ⇒ Array<Job>

Retrieves all umpires

Examples:

Get all umpires for the current season

MLB::Jobs.umpires

Get umpires for a specific season

MLB::Jobs.umpires(season: 2024)

Parameters:

  • season (Integer, nil) (defaults to: nil)

    the season year (defaults to current year)

Returns:

  • (Array<Job>)

    the umpires



28
29
30
# File 'lib/mlb/jobs.rb', line 28

def self.umpires(season: nil)
  fetch_jobs("jobs/umpires", season:)
end