Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
clairernovotny committed Apr 26, 2021
1 parent a42c930 commit 7e93a78
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal class ArmenianNumberToWordsConverter : GenderlessNumberToWordsConverter

public override string Convert(long number)
{
return Convert(number, false);
return ConvertImpl(number, false);
}

public override string ConvertToOrdinal(int number)
Expand All @@ -29,10 +29,10 @@ public override string ConvertToOrdinal(int number)
return exceptionString;
}

return Convert(number, true);
return ConvertImpl(number, true);
}

private string Convert(long number, bool isOrdinal)
private string ConvertImpl(long number, bool isOrdinal)
{
if (number == 0)
{
Expand All @@ -52,7 +52,7 @@ private string Convert(long number, bool isOrdinal)

if (number < 0)
{
return string.Format("մինուս {0}", Convert(-number, isOrdinal));
return string.Format("մինուս {0}", ConvertImpl(-number, isOrdinal));
}

var parts = new List<string>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ public string Convert(long number)
return Convert(number, _defaultGender);
}

/// <summary>
/// Converts the number to string using the locale's default gramatical gender and adds "and"
/// </summary>
/// <param name="number"></param>
/// <param name="addAnd">Whether "and" should be included.</param>
/// <returns></returns>
public string Convert(long number, bool addAnd)
{
return Convert(number, _defaultGender);
Expand All @@ -29,6 +35,7 @@ public string Convert(long number, bool addAnd)
/// </summary>
/// <param name="number"></param>
/// <param name="gender"></param>
/// <param name="addAnd"></param>
/// <returns></returns>
public abstract string Convert(long number, GrammaticalGender gender, bool addAnd = true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ internal abstract class GenderlessNumberToWordsConverter : INumberToWordsConvert
/// <returns></returns>
public abstract string Convert(long number);

/// <summary>
/// Converts the number to string
/// </summary>
/// <param name="number"></param>
/// <param name="addAnd">Whether "and" should be included.</param>
/// <returns></returns>
public virtual string Convert(long number, bool addAnd)
{
return Convert(number);
Expand All @@ -19,6 +25,7 @@ public virtual string Convert(long number, bool addAnd)
/// </summary>
/// <param name="number"></param>
/// <param name="gender"></param>
/// <param name="addAnd"></param>
/// <returns></returns>
public virtual string Convert(long number, GrammaticalGender gender, bool addAnd = true)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ internal class GreekNumberToWordsConverter : GenderlessNumberToWordsConverter

public override string Convert(long number)
{
return Convert(number, false);
return ConvertImpl(number, false);
}

public override string ConvertToOrdinal(int number)
{
return null;
}

private string Convert(long number, bool returnPluralized)
private string ConvertImpl(long number, bool returnPluralized)
{
if (number < 13)
{
Expand Down Expand Up @@ -75,7 +75,7 @@ private string ConvertIntBH(long number, bool returnPluralized)
result += " ";
}

result += Convert(number % 10, returnPluralized).ToLower();
result += ConvertImpl(number % 10, returnPluralized).ToLower();
}

return result;
Expand All @@ -101,7 +101,7 @@ private string ConvertIntBT(long number, bool returnPluralized)

if (number % 100 != 0)
{
result += $" {Convert(number % 100, returnPluralized).ToLower()}";
result += $" {ConvertImpl(number % 100, returnPluralized).ToLower()}";
}

return result;
Expand All @@ -116,14 +116,14 @@ private string ConvertIntBM(long number)
return "χίλια";
}

return $"χίλια {Convert(number % 1000, false).ToLower()}";
return $"χίλια {ConvertImpl(number % 1000, false).ToLower()}";
}

var result = $"{Convert(number / 1000, true)} χιλιάδες";
var result = $"{ConvertImpl(number / 1000, true)} χιλιάδες";

if (number % 1000 != 0)
{
result += $" {Convert(number % 1000, false).ToLower()}";
result += $" {ConvertImpl(number % 1000, false).ToLower()}";
}

return result;
Expand All @@ -138,14 +138,14 @@ private string ConvertIntBB(long number)
return "ένα εκατομμύριο";
}

return $"ένα εκατομμύριο {Convert(number % 1000000, true).ToLower()}";
return $"ένα εκατομμύριο {ConvertImpl(number % 1000000, true).ToLower()}";
}

var result = $"{Convert(number / 1000000, false)} εκατομμύρια";
var result = $"{ConvertImpl(number / 1000000, false)} εκατομμύρια";

if (number % 1000000 != 0)
{
result += $" {Convert(number % 1000000, false).ToLower()}";
result += $" {ConvertImpl(number % 1000000, false).ToLower()}";
}

return result;
Expand All @@ -160,14 +160,14 @@ private string ConvertIntBTR(long number)
return "ένα δισεκατομμύριο";
}

return $"ένα δισεκατομμύριο {Convert(number % 1000000000, true).ToLower()}";
return $"ένα δισεκατομμύριο {ConvertImpl(number % 1000000000, true).ToLower()}";
}

var result = $"{Convert(number / 1000000000, false)} δισεκατομμύρια";
var result = $"{ConvertImpl(number / 1000000000, false)} δισεκατομμύρια";

if (number % 1000000000 != 0)
{
result += $" {Convert(number % 1000000000, false).ToLower()}";
result += $" {ConvertImpl(number % 1000000000, false).ToLower()}";
}

return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public interface INumberToWordsConverter
/// Converts the number to string using the locale's default grammatical gender with or without adding 'And'
/// </summary>
/// <param name="number"></param>
/// <param name="addAnd">Specify with our without adding "And"</param>
/// <returns></returns>
string Convert(long number, bool addAnd);

Expand All @@ -24,6 +25,7 @@ public interface INumberToWordsConverter
/// </summary>
/// <param name="number"></param>
/// <param name="gender"></param>
/// <param name="addAnd"></param>
/// <returns></returns>
string Convert(long number, GrammaticalGender gender, bool addAnd = true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ internal class JapaneseNumberToWordsConverter : GenderlessNumberToWordsConverter

public override string Convert(long number)
{
return Convert(number, false);
return ConvertImpl(number, false);
}

public override string ConvertToOrdinal(int number)
{
return Convert(number, true);
return ConvertImpl(number, true);
}

private string Convert(long number, bool isOrdinal)
private string ConvertImpl(long number, bool isOrdinal)
{
if (number == 0)
{
Expand All @@ -28,7 +28,7 @@ private string Convert(long number, bool isOrdinal)

if (number < 0)
{
return string.Format("マイナス {0}", Convert(-number, false));
return string.Format("マイナス {0}", ConvertImpl(-number, false));
}

var parts = new List<string>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ internal class TamilNumberToWordsConverter : GenderlessNumberToWordsConverter

public override string Convert(long number)
{
return Convert(number, false);
return ConvertImpl(number, false);
}

public override string ConvertToOrdinal(int number)
{
return Convert(number, true);
return ConvertImpl(number, true);
}

private string Convert(long number, bool isOrdinal)
private string ConvertImpl(long number, bool isOrdinal)
{
if (number == 0)
return GetUnitValue(0, isOrdinal);
Expand Down
3 changes: 2 additions & 1 deletion src/Humanizer/NumberToWordsExtension.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Globalization;
using System.Globalization;
using Humanizer.Configuration;

namespace Humanizer
Expand Down Expand Up @@ -62,6 +62,7 @@ public static string ToWords(this int number, GrammaticalGender gender, CultureI
/// </summary>
/// <param name="number">Number to be turned to words</param>
/// <param name="culture">Culture to use. If null, current thread's UI culture is used.</param>
/// <param name="addAnd">Whether "and" should be included or not.</param>
/// <returns></returns>
public static string ToWords(this long number, CultureInfo culture = null, bool addAnd = true)
{
Expand Down

0 comments on commit 7e93a78

Please sign in to comment.