class SC2Cli::Subcommands::HistoryShared::HistoryMatches

Public Class Methods

new(json:) click to toggle source
# File lib/sc2cli/subcommands/history/historymatches.rb, line 23
def initialize(json:)
  @matches = Array.new

  if json.key?("matches") then
    matches = json["matches"]
    @@console.fatal("Returned history information matches is not an array!") unless matches.kind_of?(Array)

    matches.each do |match|
      match = HistoryMatch.new(json: match)
      add(match: match)
    end
  end
end

Public Instance Methods

add(match:) click to toggle source
# File lib/sc2cli/subcommands/history/historymatches.rb, line 39
def add(match:)
  @matches << match if match.kind_of?(HistoryMatch)
  @matches.sort_by!{ |match| match.date }.reverse!
end
to_s() click to toggle source
# File lib/sc2cli/subcommands/history/historymatches.rb, line 46
def to_s
  result = String.new

  @matches.each do |match|
    result += match.to_s
  end

  return result
end