You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: percentile.rb
    path of file: ./repos/facets/lib/standard/facets/math
    
    the code of the file until where you have to start completion: module Math

  # Returns the percentile value for percentile _pcnt_; nil if array is empty.
  #
  # +p
    
  def self.percentile(array, pcnt)
    sorted_array = array.sort

    return nil if array.length == 0

    rank  = (pcnt.to_f / 100) * (array.length + 1)
    whole = rank.truncate
 
    # if has fractional part
    if whole != rank
      s0 = sorted_array[whole - 1]
      s1 = sorted_array[whole]

      f = (rank - rank.truncate).abs

      return (f * (s1 - s0)) + s0
    else
      return sorted_array[whole - 1]
    end