module SportsRegion
SportsRegion — region keyword matching for SportScore match hashes. Public: match_region?, keywords_for Tests: test/lib/sports_region_test.rb
Constants
- KEYWORDS
Public Instance Methods
Source
# File lib/sports_region.rb, line 39 def keywords_for(code) KEYWORDS.fetch(code.to_s.downcase, []) end
Source
# File lib/sports_region.rb, line 43 def match_region?(match, region_code) haystack = searchable_text(match) keywords_for(region_code).any? { |keyword| haystack.include?(keyword) } end
Source
# File lib/sports_region.rb, line 48 def searchable_text(match) [ match["home"], match["away"], match["competition"] ].compact.join(" ").downcase end