class SC2Cli::Subcommands::LeagueShared::LeagueTiers

Attributes

colour[R]
name[R]

Public Class Methods

new(name:, colour:, json:) click to toggle source
# File lib/sc2cli/subcommands/league/leaguetiers.rb, line 28
def initialize(name:, colour:, json:)
  @name   = name
  @colour = colour
  @tiers  = Array.new

  if json.key?("tier") then
    tiers = json["tier"]
    @@console.fatal("Returned league information for: #{name} tiers is not an array!") unless tiers.kind_of?(Array)

    tiers.each do |tier|
      tier = LeagueTier.new(league: @name, colour: @colour, json: tier)
      add(tier: tier)
    end
  end
end

Public Instance Methods

add(tier:) click to toggle source
# File lib/sc2cli/subcommands/league/leaguetiers.rb, line 46
def add(tier:)
  @tiers << tier if tier.kind_of?(LeagueTier)
  @tiers.sort_by!{ |tier| tier.id }
end
to_s() click to toggle source
# File lib/sc2cli/subcommands/league/leaguetiers.rb, line 53
def to_s
  result = String.new

  @tiers.each do |tier|
    result += tier.to_s
  end

  return result
end