From 3caee9d48c6bf59a073253058b08b076691adadd Mon Sep 17 00:00:00 2001 From: George Hahn Date: Sat, 5 Jul 2014 20:19:24 -0400 Subject: [PATCH] Added byte rate calculation functons, closes #296 --- src/Humanizer.Tests/Humanizer.Tests.csproj | 1 + src/Humanizer/Bytes/ByteSizeExtensions.cs | 14 +++++++++++++- src/Humanizer/Humanizer.csproj | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Humanizer.Tests/Humanizer.Tests.csproj b/src/Humanizer.Tests/Humanizer.Tests.csproj index b39cce5b1..68e40ad4c 100644 --- a/src/Humanizer.Tests/Humanizer.Tests.csproj +++ b/src/Humanizer.Tests/Humanizer.Tests.csproj @@ -56,6 +56,7 @@ + diff --git a/src/Humanizer/Bytes/ByteSizeExtensions.cs b/src/Humanizer/Bytes/ByteSizeExtensions.cs index d057dc9e3..2fbd7a784 100644 --- a/src/Humanizer/Bytes/ByteSizeExtensions.cs +++ b/src/Humanizer/Bytes/ByteSizeExtensions.cs @@ -1,4 +1,5 @@ -using Humanizer.Bytes; +using System; +using Humanizer.Bytes; // ReSharper disable once CheckNamespace namespace Humanizer @@ -438,5 +439,16 @@ public static string Humanize(this ByteSize input, string format = null) { return string.IsNullOrWhiteSpace(format) ? input.ToString() : input.ToString(format); } + + /// + /// Turns a quantity of bytes in a given interval into a rate that can be manipulated + /// + /// Quantity of bytes + /// Interval to create rate for + /// + public static ByteRate Per(this ByteSize size, TimeSpan interval) + { + return new ByteRate(size, interval); + } } } diff --git a/src/Humanizer/Humanizer.csproj b/src/Humanizer/Humanizer.csproj index a3571b6bb..4e9a5c7ad 100644 --- a/src/Humanizer/Humanizer.csproj +++ b/src/Humanizer/Humanizer.csproj @@ -49,6 +49,7 @@ Humanizer.snk +