Sha256: a06d4df03f8dec1afcc641188924b3b985279c288b5427302bc697fa9b2ab7e2

Contents?: true

Size: 485 Bytes

Versions: 1

Compression:

Stored size: 485 Bytes

Contents

module AtpScraper
  # Utility class
  class Utility
    # "62 765" -> "62 76(5)"
    # "768 64 46 46 76-74" -> "76(8) 64 46 46 76-74"
    # "76 63" -> "76 64"
    def self.convert_score(score)
      result = []
      score.split("\s").each do |s|
        # Str starts '76' or '67' (not '76-' or '67-')
        if (a = s.slice!(/^(76|67)(?!-|$)/))
          result.push("#{a}(#{s})")
        else
          result.push(s)
        end
      end
      result.join("\s")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
atp_scraper-0.7.2 lib/atp_scraper/utility.rb