Skip to content

Commit

Permalink
Merge pull request #22 from stscoundrel/feature/static-mappings
Browse files Browse the repository at this point in the history
Mappings: stricter access, move to static members
  • Loading branch information
stscoundrel authored Apr 27, 2022
2 parents f73c4e8 + 033560f commit 6450b74
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 37 deletions.
20 changes: 12 additions & 8 deletions src/Mappings/ElderFutharkMapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@

namespace Riimut.Mappings
{
public class ElderFutharkMapping
internal class ElderFutharkMapping
{
public static Dictionary<string, string> GetLettersToRunesDictionary()
{
return new Dictionary<string, string>()

private readonly static Dictionary<string, string> LettersToRunesMapping = new Dictionary<string, string>()
{
{"a", ""},
{"á", ""},
Expand Down Expand Up @@ -52,11 +51,8 @@ public static Dictionary<string, string> GetLettersToRunesDictionary()
{"þ", ""},
{" ", ":"},
};
}

public static Dictionary<string, string> GetRunesToLettersDictionary()
{
return new Dictionary<string, string>()
private readonly static Dictionary<string, string> RunesToLettersMapping = new Dictionary<string, string>()
{
{"", "f"},
{"", "u"},
Expand Down Expand Up @@ -87,6 +83,14 @@ public static Dictionary<string, string> GetRunesToLettersDictionary()
{"", "d"},
{":", " "},
};
public static Dictionary<string, string> GetLettersToRunesDictionary()
{
return LettersToRunesMapping;
}

public static Dictionary<string, string> GetRunesToLettersDictionary()
{
return RunesToLettersMapping;
}
}
}
20 changes: 12 additions & 8 deletions src/Mappings/FuthorcMapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@

namespace Riimut.Mappings
{
public class FuthorcMapping
internal class FuthorcMapping
{
public static Dictionary<string, string> GetLettersToRunesDictionary()
{
return new Dictionary<string, string>()
private readonly static Dictionary<string, string> LettersToRunesMapping = new Dictionary<string, string>()
{
{"a", ""},
{"á", ""},
Expand Down Expand Up @@ -55,11 +53,8 @@ public static Dictionary<string, string> GetLettersToRunesDictionary()
{"þ", ""},
{" ", ":"},
};
}

public static Dictionary<string, string> GetRunesToLettersDictionary()
{
return new Dictionary<string, string>()
private readonly static Dictionary<string, string> RunesToLettersMapping = new Dictionary<string, string>()
{
{"", "f"},
{"", "u"},
Expand Down Expand Up @@ -93,6 +88,15 @@ public static Dictionary<string, string> GetRunesToLettersDictionary()
{":", " "},
{"", "ea"},
};

public static Dictionary<string, string> GetLettersToRunesDictionary()
{
return LettersToRunesMapping;
}

public static Dictionary<string, string> GetRunesToLettersDictionary()
{
return RunesToLettersMapping;
}
}
}
19 changes: 11 additions & 8 deletions src/Mappings/MedievalFuthorkMapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@

namespace Riimut.Mappings
{
public class MedievalFuthorkMapping
internal class MedievalFuthorkMapping
{
public static Dictionary<string, string> GetLettersToRunesDictionary()
{
return new Dictionary<string, string>()
private readonly static Dictionary<string, string> LettersToRunesMapping = new Dictionary<string, string>()
{
{"a", ""},
{"á", ""},
Expand Down Expand Up @@ -53,11 +51,8 @@ public static Dictionary<string, string> GetLettersToRunesDictionary()
{"þ", ""},
{" ", ":"},
};
}

public static Dictionary<string, string> GetRunesToLettersDictionary()
{
return new Dictionary<string, string>()
private readonly static Dictionary<string, string> RunesToLettersMapping = new Dictionary<string, string>()
{
{"", "f"},
{"", "u"},
Expand Down Expand Up @@ -87,6 +82,14 @@ public static Dictionary<string, string> GetRunesToLettersDictionary()
{"", "e"},
{"", "g"},
};
public static Dictionary<string, string> GetLettersToRunesDictionary()
{
return LettersToRunesMapping;
}

public static Dictionary<string, string> GetRunesToLettersDictionary()
{
return RunesToLettersMapping;
}
}
}
19 changes: 11 additions & 8 deletions src/Mappings/YoungerFutharkMapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@

namespace Riimut.Mappings
{
public class YoungerFutharkMapping
internal class YoungerFutharkMapping
{
public static Dictionary<string, string> GetLettersToRunesDictionary()
{
return new Dictionary<string, string>()
private readonly static Dictionary<string, string> LettersToRunesMapping = new Dictionary<string, string>()
{
{"a", ""},
{"á", ""},
Expand Down Expand Up @@ -51,11 +49,8 @@ public static Dictionary<string, string> GetLettersToRunesDictionary()
{"ǫ", ""},
{" ", ":"},
};
}

public static Dictionary<string, string> GetRunesToLettersDictionary()
{
return new Dictionary<string, string>()
private readonly static Dictionary<string, string> RunesToLettersMapping = new Dictionary<string, string>()
{
{"", "f"},
{"", "u"},
Expand All @@ -80,6 +75,14 @@ public static Dictionary<string, string> GetRunesToLettersDictionary()
{"", "R"},
{":", " "},
};
public static Dictionary<string, string> GetLettersToRunesDictionary()
{
return LettersToRunesMapping;
}

public static Dictionary<string, string> GetRunesToLettersDictionary()
{
return RunesToLettersMapping;
}
}
}
10 changes: 7 additions & 3 deletions src/Transform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ public static string WithDictionary(string content, Dictionary<string, string> d
{
StringBuilder result = new StringBuilder();

foreach (char letter in content) {
foreach (char letter in content)
{
string part = Char.ToLower(letter).ToString();
if (dictionary.ContainsKey(part)) {
if (dictionary.ContainsKey(part))
{
result.Append(dictionary[part]);
} else {
}
else
{
result.Append(part);
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/YoungerFutharkTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void Transforms_Text_Content_To_Younger_Futhark()
public void Transforms_Runes_To_Letters()
{
string runes = "ᚠᚢᚦᚬᚱᚴᚼᚽᚾᚿᛁᛅᛆᛋᛌᛏᛐᛒᛘᛚᛦ:";
string letters ="fuþorkhhnniaassttbmlR ";
string letters = "fuþorkhhnniaassttbmlR ";

string result = YoungerFuthark.RunesToLetters(runes);

Expand All @@ -45,7 +45,7 @@ public void Transforms_Rune_Content_To_Latin_Letters()
{
// From Old Groms runestone.
string runes = "ᛅᚢᚴ:ᛏᛅᚾᛁ:ᚴᛅᚱᚦᛁ:ᚴᚱᛁᛋᛏᚾᛅ";
string letters ="auk tani karþi kristna";
string letters = "auk tani karþi kristna";

string result = YoungerFuthark.RunesToLetters(runes);

Expand Down

0 comments on commit 6450b74

Please sign in to comment.