Skip to content

Commit

Permalink
Added byte rate calculation functons, closes Humanizr#296
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeHahn committed Jul 6, 2014
1 parent 237ecd1 commit 3caee9d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Humanizer.Tests/Humanizer.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Bytes\ByteRateTests.cs" />
<Compile Include="Bytes\ComparingTests.cs" />
<Compile Include="Bytes\CreatingTests.cs" />
<Compile Include="Bytes\ByteSizeExtensionsTests.cs" />
Expand Down
14 changes: 13 additions & 1 deletion src/Humanizer/Bytes/ByteSizeExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Humanizer.Bytes;
using System;
using Humanizer.Bytes;

// ReSharper disable once CheckNamespace
namespace Humanizer
Expand Down Expand Up @@ -438,5 +439,16 @@ public static string Humanize(this ByteSize input, string format = null)
{
return string.IsNullOrWhiteSpace(format) ? input.ToString() : input.ToString(format);
}

/// <summary>
/// Turns a quantity of bytes in a given interval into a rate that can be manipulated
/// </summary>
/// <param name="size">Quantity of bytes</param>
/// <param name="interval">Interval to create rate for</param>
/// <returns></returns>
public static ByteRate Per(this ByteSize size, TimeSpan interval)
{
return new ByteRate(size, interval);
}
}
}
1 change: 1 addition & 0 deletions src/Humanizer/Humanizer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<AssemblyOriginatorKeyFile>Humanizer.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Compile Include="Bytes\ByteRate.cs" />
<Compile Include="CollectionHumanizeExtensions.cs" />
<Compile Include="Configuration\CollectionFormatterRegistry.cs" />
<Compile Include="Localisation\CollectionFormatters\DefaultCollectionFormatter.cs" />
Expand Down

0 comments on commit 3caee9d

Please sign in to comment.