Class: Twitch::V2::Teams

Inherits:
Object
  • Object
show all
Defined in:
lib/kappa/team.rb

Overview

Query class for finding all active teams.

See Also:

Instance Method Summary collapse

Instance Method Details

#all(options = {}) {|team| ... } ⇒ Array<Team>?

Get the list of all active teams.

Examples:

Twitch.teams.all
Twitch.teams.all(:limit => 10)
Twitch.teams do |team|
  next if (Time.now - team.updated_at) > (60 * 60 * 24)
  puts team.url
end

Parameters:

  • options (Hash) (defaults to: {})

    Filter criteria.

Options Hash (options):

  • :limit (Fixnum) — default: nil

    Limit on the number of results returned.

Yields:

  • Optional. If a block is given, each team is yielded.

Yield Parameters:

  • team (Team)

    Current team.

Returns:

  • (Array<Team>)

    All active teams, if no block is given.

  • (nil)

    If a block is given.

See Also:



121
122
123
124
125
126
127
128
129
130
# File 'lib/kappa/team.rb', line 121

def all(options = {}, &block)
  return @query.connection.accumulate(
    :path => 'teams',
    :json => 'teams',
    :create => Team,
    :limit => options[:limit],
    :offset => options[:offset],
    &block
  )
end

#get(team_name) ⇒ Team

Get a team by name.

Examples:

Twitch.teams.get('teamliquid')

Parameters:

  • team_name (String)

    The name of the team to get.

Returns:

  • (Team)

    A valid Team object if the team exists, nil otherwise.

See Also:



96
97
98
99
100
101
102
# File 'lib/kappa/team.rb', line 96

def get(team_name)
  name = CGI.escape(team_name)
  Twitch::Status.map(404 => nil) do
    json = @query.connection.get("teams/#{name}")
    Team.new(json)
  end
end