use Sub::Exporter -setup => {
exports => [
- qw(successful_sequential_posts days_remaining_to_post)
+ qw(successful_sequential_posts days_remaining_to_post level_for_post_count)
]
};
return check_both(\&check_time_remaining, @posts);
}
+sub level_for_post_count($count) {
+ return 'paper' if $count < 4;
+ return 'stone' if $count < 12;
+ return 'bronze' if $count < 36;
+ return 'iron';
+}
+
1;
--- /dev/null
+use strict;
+use warnings;
+use Test::More qw(no_plan);
+
+BEGIN {
+ use_ok 'IronMunger::Calculate', 'level_for_post_count';
+}
+
+my @spec = qw(
+ 0 paper
+ 3 paper
+ 4 stone
+ 11 stone
+ 12 bronze
+ 35 bronze
+ 36 iron
+ 50 iron
+);
+
+while (@spec > 2) {
+ my ($count, $level) = (shift(@spec),shift(@spec));
+ is(level_for_post_count($count), $level, "${count} posts means ${level} man");
+}