Sha256: d8927777353bd4aac8f9c3110b0d9f31980d1060f96ebe293da4fa9bd3b219ad

Contents?: true

Size: 602 Bytes

Versions: 1

Compression:

Stored size: 602 Bytes

Contents

require 'crew_check/team'

require 'octokit'

module CrewCheck
  class TeamList
    include Enumerable

    def initialize(github_teams = [])
      @teams = github_teams.map do |gh_team|
        CrewCheck::Team.new(gh_team)
      end
    end

    def shorthand_names
      @teams.map do |team|
        team.shorthand_name
      end
    end

    class << self
      def fetch(token)
        client = Octokit::Client.new(access_token: token)
        new(client.user_teams)
      end
    end

    def each(&block)
      @teams.each(&block)
    end

    def empty?
      @teams.size == 0
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
omniauth-crew-check-0.0.2 lib/crew_check/team_list.rb