class YieldParser

  Result = Struct.new(:number, :label)

  def self.parse(yield_string)

    begin
      vu = UnitConversion::parse(yield_string)
    rescue UnparseableUnitError
      vu = nil
    end

    case
      when vu.nil?
        nil
      when vu.unit.nil?
        Result.new(vu.raw_value.to_f, 'each')
      else
        Result.new(vu.raw_value.to_f, vu.unit.to_s.singularize)
    end
  end

end