BoardGameGeekApiClient.Helpers.BoardGameGeekApiClientHelper.GetRanking C# (CSharp) Method

GetRanking() public static method

public static GetRanking ( this rankingElement ) : int
rankingElement this
return int
        public static int GetRanking(this XElement rankingElement)
        {
            var val = (rankingElement.Elements("rank")
                .Where(p => p.Attribute("id").Value == "1")
                .Select(p => p.Attribute("value").Value)).SingleOrDefault();
            int rank;

            if (val == null)
                rank = -1;
            else if (val.ToLower().Trim() == "not ranked")
                rank = -1;
            else if (!int.TryParse(val, out rank))
                rank = -1;

            return rank;
        }
    }