Sets an array of the city names for the teams playing the game
    [0] = away
    [1] = home
963886
def set_cities
      @cities = []
      if @xml_doc.root
        @cities.push @xml_doc.root.attributes["away_sname"]
        @cities.push @xml_doc.root.attributes["home_sname"]
      else
        @cities.push 'unknown'
        @cities.push 'unknown'
      end
    end
1369966
def select
      new_array = []
      @array.size.times do |index|
        value = @array[index]
        if yield(value)
          new_array << value
        end
      end

      new_array
    end
1271025
def update_rosters(game, away_id, home_id)
        game_id = find_or_create_game(game, nil, nil)
      
        gameday_info = GamedayUtil.parse_gameday_id('gid_' + game.gid)
        active_date = "#{gameday_info['year']}/#{gameday_info['month']}/#{gameday_info['day']}"
      
        away_res = @db.query("select id from rosters where team_id = '#{away_id}' and active_date = '#{active_date}'")
        away_roster_id=0
      
        found = false
        away_res.each do |row|
          found = true
          away_roster_id = row['id']
        end

        @db.query("UPDATE rosters SET game_id = '#{game_id}', home_or_away = 'a' WHERE id = '#{away_roster_id}'")

        home_res = @db.query("select id from rosters where team_id = '#{home_id}' and active_date = '#{active_date}'")
        home_roster_id=0
      
      
        found = false
        home_res.each do |row|
          found = true
          home_roster_id = row['id']
        end
      
        @db.query("UPDATE rosters SET game_id = '#{game_id}', home_or_away = 'h' WHERE id = '#{home_roster_id}'")
      end
1077789
function(){
            // Compute team Wins, Losts, Draws and Goal-Sum
            /*
                // Uses the key as the teamId
                {
                         1: {P: x, S: y, [...]},
                    teamId: {P: x, S: y, [...]}
                 }
            */
            var rawTable = {};
            var _default = {rank: 0, teamId: 0, P: 0, goalsMade: 0, goalsTaken: 0, S: 0, W: 0, D: 0, L: 0, score: 0};

            for(var k in this.matches){
                var match = this.matches[k];

                // Compute game points for both teams
                computeGame(match, match.teamAId, match.teamAScore, match.teamBScore);
                computeGame(match, match.teamBId, match.teamBScore, match.teamAScore);
            }

            // Adds game to the teamId. Should be runned twice for each
            // side of match (teamA and teamB).
            function computeGame(match, teamId, goalsMade, goalsTaken){
                // Skip empty id's
                if(!teamId)
                    return;

                // Generate default template if NOT in array yet
                if(!rawTable[teamId]){
                    var teamRow = _.clone(_default);
                    // Keeps team id under team
                    teamRow.teamId = teamId;
                    // Inserts team in rawTable
                    rawTable[teamId] = teamRow;
                }

                // Get teamRow (it is supposed to exist)
                var teamRow = rawTable[teamId];

                // Compute points ONLY if match is not 'scheduled'
                // logycaly, it's 'ended' or 'playing', so we compute it
                if(match.state == 'scheduled')
                    return;

                // Increment Plays
                teamRow.P++;

                // Compute goals made/taken
                teamRow.goalsMade += goalsMade*1;
                teamRow.goalsTaken += goalsTaken*1;

                // Win
                if(goalsMade > goalsTaken)
                    teamRow.W ++;
                // Loose
                else if(goalsMade < goalsTaken)
                    teamRow.L ++;
                // Drew
                else
                    teamRow.D ++;
            }

            // Compute 'final score' and add column S (goalsMade:goalsTaken)
            // Transfer data to final table array
            var finalTable = [];
            _.forEach(rawTable, function(row){
                row.score = row.W*3 + row.D*1;
                row.S = row.goalsMade*1 + ':' + row.goalsTaken*1;
                row.GD = row.goalsMade*1 - row.goalsTaken*1;

                finalTable.push(row);
            });

            // Sort by 'score' field
            finalTable = _.sortBy(finalTable, 'score').reverse();

            // Rank Table
            var pos = 0;
            var lastScore = -1;

            _.forEach(finalTable, function(row){
                // Keeps the same ranking if scores is the same
                if(lastScore != row.score){
                    pos++;
                    lastScore = row.score;
                }

                row.rank = pos;
            });


            return finalTable;


        }
532500
def all_away_games(year)
      games = all_games(year)
      results = games.select {|g| g.visit_team_abbrev == @abrev }
    end
1283996
public function setData( array $array ) {
        foreach( $array as $name=>$value ) {
            if( !isset( $this->nameHash[$name] ) ) {
                continue;
            }

            $element = $this->nameHash[$name];

            $element->setAttribute( 'value', (string)$value );
        }
    }
941401
def _set_players(self, _players):
        
        self._players = list()
        _players = list(_players)
        _players.sort(key=lambda p: p.seat)
        for p in _players:
            self._players.append(p)
617769
function set(from, to) {
    for (var key in to) {
        if (!from.hasOwnProperty(key)) {
            continue;
        }

        var value = from[key];

        if (value instanceof Array) {
            to[key] = [].concat(value);
        } else {
            to[key] = value;
        }
    }

    return to;
}
1143566
def set_local(self, value, variable_name):
        '''
        
        '''
        self.log('assigning %s = %r', variable_name, value)
        self._locals[variable_name] = value
        return value
1180416
function computeGame(match, teamId, goalsMade, goalsTaken){
                // Skip empty id's
                if(!teamId)
                    return;

                // Generate default template if NOT in array yet
                if(!rawTable[teamId]){
                    var teamRow = _.clone(_default);
                    // Keeps team id under team
                    teamRow.teamId = teamId;
                    // Inserts team in rawTable
                    rawTable[teamId] = teamRow;
                }

                // Get teamRow (it is supposed to exist)
                var teamRow = rawTable[teamId];

                // Compute points ONLY if match is not 'scheduled'
                // logycaly, it's 'ended' or 'playing', so we compute it
                if(match.state == 'scheduled')
                    return;

                // Increment Plays
                teamRow.P++;

                // Compute goals made/taken
                teamRow.goalsMade += goalsMade*1;
                teamRow.goalsTaken += goalsTaken*1;

                // Win
                if(goalsMade > goalsTaken)
                    teamRow.W ++;
                // Loose
                else if(goalsMade < goalsTaken)
                    teamRow.L ++;
                // Drew
                else
                    teamRow.D ++;
            }
122493
def get_pitchers(home_or_away)
      if self.gid
        bs = get_boxscore
        if home_or_away == 'away'
          bs.pitchers[0]
        else
          bs.pitchers[1]
        end
      else
        puts "No data for input specified"
      end
    end
567938
function(k, v, a) {
      for (var n = 0; n < a.length; ++n) {
        if (v === a[n]) {
          this.set(k, v);
          break;
        }
      }
    }
1283071
def get_score
      results = []
      ls = get_boxscore.linescore
      results << ls.away_team_runs
      results << ls.home_team_runs
      results
    end
38459
function setIndexInfo(name, origWhere, origSort) {
    origWhere = origWhere || {};
    origSort = origSort || {};

    // if _id in where, then don't do anything (no index value needed)
    if (origWhere._id) {
        return;
    }

    // we need to clean out values from inputs
    var whereNames = [], where = {}, whereSorted = {};
    _.each(origWhere, function (val, key) {
        whereNames.push(key);
        where[key] = 1;
    });
    _.each(whereNames.sort(), function (key) {
        whereSorted[key] = 1;
    });

    var sortNames = [], sort = {}, sortSorted = {};
    _.each(origSort, function (val, key) {
        sortNames.push(key);
        sort[key] = origSort[key];
    });
    _.each(sortNames.sort(), function (key) {
        sortSorted[key] = origSort[key];
    });

    var json = {
        name: name,
        where: where,
        sort: sort
    };
    var str = JSON.stringify(json);
    //var jsonSorted = {
    //    name: name,
    //    where: whereSorted,
    //    sort: sortSorted
    //};
    //var strSorted = JSON.stringify(jsonSorted);

    var query = cache.idxInfo[str] = cache.idxInfo[str] || {
        str: str,
        name: name,
        count: 0
    };

    query.count++;

    // if past the interval, then save the updates
    var now = (new Date()).getTime();
    if ((now - idxInfoLastSave) > idxInfoInterval) {
        idxInfoLastSave = now;
        saveIndexInfo();
    }
}
722130
def set_totals(element)
        element.elements.each("linescore/r") { |runs|
           @away_runs = runs.attributes['away']
           @home_runs = runs.attributes['home']
        }
        element.elements.each("linescore/h") { |hits|
           @away_hits = hits.attributes['away']
           @home_hits = hits.attributes['home']
        }
        element.elements.each("linescore/e") { |errs|
           @away_errors = errs.attributes['away']
           @home_errors = errs.attributes['home']
        }
      end
1301883
def games(years, months=None, days=None, home=None, away=None):
    
    # put in data if months and days are not specified
    if months is None:
        months = list(range(1, 13))
    if days is None:
        days = list(range(1, 32))
    results = []
    # check if lists, if not make lists
    # allows users to input either numbers or lists
    if not isinstance(years, list):
        years = [years]
    if not isinstance(months, list):
        months = [months]
    if not isinstance(days, list):
        days = [days]
    for i in years:
        for y in months:
            # get the days in a month
            daysinmonth = calendar.monthrange(i, y)[1]
            for x in days:
                if daysinmonth >= x:
                    # use the day function to get data for each day in range
                    game = day(i, y, x, home=home, away=away)
                    if game:
                        results.append(game)
    return results
256012
def set_column_names(self, column_names):
        
        if len(self._rows):
            raise NotImplementedError("You can't manually set columns once data has been added")

        self._update_internal_column_state(column_names)