Sha256: 8b68d6c839c7cf02088524196375b7af953bbe5a583795c07e1c7aa3091cb35d

Contents?: true

Size: 1.42 KB

Versions: 2

Compression:

Stored size: 1.42 KB

Contents

# frozen-string-literal: true

module SleeperRb
  module Resources
    class League
      ##
      # Implements {SleeperRb::Utilities::ArrayProxy} and wraps Transaction objects.
      class TransactionArray < SleeperRb::Utilities::ArrayProxy
        ##
        # Returns transactions which are trades.
        #
        # @return [{SleeperRb::Resources::League::TransactionArray}[rdoc-ref:SleeperRb::Resources::League::TransactionArray]]
        def trade
          where(type: "trade")
        end

        ##
        # Returns transactions which are free agent acquisitions.
        #
        # @return [{SleeperRb::Resources::League::TransactionArray}[rdoc-ref:SleeperRb::Resources::League::TransactionArray]]
        def free_agent
          where(type: "free_agent")
        end

        ##
        # Returns transactions which are free agent acquisitions made with FAAB.
        #
        # @return [{SleeperRb::Resources::League::TransactionArray}[rdoc-ref:SleeperRb::Resources::League::TransactionArray]]
        def faab
          where(type: "free_agent", waiver_bid: { not: nil })
        end

        ##
        # Returns transactions which are free agent acquisitions made via the waiver wire.
        #
        # @return [{SleeperRb::Resources::League::TransactionArray}[rdoc-ref:SleeperRb::Resources::League::TransactionArray]]
        def waiver
          where(type: "free_agent", waiver_bid: nil)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sleeper_rb-0.2.1 lib/sleeper_rb/resources/league/transaction_array.rb
sleeper_rb-0.2.0 lib/sleeper_rb/resources/league/transaction_array.rb