footballdb-leagues Gem - Match the World's Top 100+ Football Leagues & Cups
Gerald Bauer <[email protected]> Wed, 23 Oct 2019 19:47:29 +0200
| Newsgroups | gmane.comp.lang.ruby.general |
|---|---|
| Message-ID | <CAAxEZd8iyiXCGSdW0LpN+fcMi0bN9uY2VB_SDMoLkMicjcZ__A@mail.gmail.com> |
Hello, I've put together the footballdb-leagues gem / library [1] that bundles-up an all-in-one football.db /leagues datafile and lets you match 100+ football league & cup names from around the world "out-of-the-gem / box" with zero-configuration. It's as easy as: ``` require 'footballdb/leagues' pp League.all ``` resulting in: ``` [#<League @name="English Premier League", @country="England", ...>, #<League @name="English Championship", @country="England", ...>, #<League @name="English League One", @country="England", ...>, #<League @name="English League Two", @country="England", ...>, ... ] ``` Let's find football leagues in the world that run with the name `Premier League`: ``` m = League.match( 'Premier League' ) m.size # 7 league matches found #=> 7 m[0].name; m[0].country #=> "English Premier League", "England" m[1].name; m[1].country #=> "Welsh Premier League", "Wales" m[2].name; m[2].country #=> "Russian Premier League", "Russia" # ... m = League.match_by( name: 'Premier League', country: 'eng' ) # -or- try more alternative (unique) names m = League.match( 'England Premier League' ) m = League.match( 'ENG 1' ) m = League.match( 'ENG PL' ) m.size # 1 league match found #=> 1 m[0].name; m[0].country #=> "English Premier League", "England" m = League.match_by( name: 'Premier League', country: 'ru' ) # -or- try more alternative (unique) names m = League.match( 'Russia Premier League' ) m = League.match( 'RUS 1' ) m = League.match( 'RUS PL' ) m.size # 1 league match found #=> 1 m[0].name; m[0].country #=> "Russian Premier League", "Russia" ... ``` And so on and so forth. Enjoy the beautiful game. Happy data wrangling with ruby. Cheers. Prost. PS: Trivia Quiz: What league will League.match( 'NB I' ) match? [1] https://github.com/sportdb/sport.db/tree/master/footballdb-leagues [2] https://github.com/sportdb/sport.db/blob/master/footballdb-leagues/config/leagues.txt Unsubscribe: <mailto:[email protected]?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>