module Fbe::Award::PTerm

def to_p(any)

def to_p(any)
  case any
  when PTerm
    any.to_s
  when Symbol
    s = any.to_s
    subs = {
      0 => '₀',
      1 => '₁',
      2 => '₂',
      3 => '₃',
      4 => '₄',
      5 => '₅',
      6 => '₆',
      7 => '₇',
      8 => '₈',
      9 => '₉'
    }
    s.gsub!(/([a-z]+)([0-9])/) { |_| "#{Regexp.last_match[1]}#{subs[Regexp.last_match[2].to_i]}" }
    "_#{s.tr('_', '-')}_"
  when Integer, Float
    "**#{any}**"
  else
    any
  end
end