Created
January 9, 2014 01:10
-
-
Save randydailey/8327687 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| + (NSString *)stringForBucketedHours:(int)seconds | |
| { | |
| NSArray *buckets = [NSArray arrayWithObjects:@1,@3, @10, @24, @48, @96, nil]; | |
| return [NSString stringWithFormat:@"%@ hours", [GSAnalyticsProvider bucket:(seconds/3600.0f) andStep:buckets]]; | |
| } | |
| + (NSString *)stringForBucketedMeters:(int)meters | |
| { | |
| NSArray *buckets = [NSArray arrayWithObjects:@20, @50, @100, @150, @200, @500, @1000, @5000, nil]; | |
| return [NSString stringWithFormat:@"%@ meters", [GSAnalyticsProvider bucket:meters andStep:buckets]]; | |
| } | |
| + (NSString *)stringForBucketedFeet:(int)feet | |
| { | |
| NSArray *buckets = [NSArray arrayWithObjects:@50, @200, @500, @1000, @2500, @5000, nil]; | |
| return [NSString stringWithFormat:@"%@ feet", [GSAnalyticsProvider bucket:feet andStep:buckets]]; | |
| } | |
| + (NSString *)stringForBucketedVehicles:(int)trains | |
| { | |
| NSArray *buckets = [NSArray arrayWithObjects:@0, @1, @2, @4, @8, nil]; | |
| return [NSString stringWithFormat:@"%@ vehicles", [GSAnalyticsProvider bucket:trains andStep:buckets]]; | |
| } | |
| + (NSString *)stringForBucketedFavorites:(int)favorites | |
| { | |
| if (favorites < 6) return [NSString stringWithFormat:@"%d", favorites]; | |
| return @"6+"; | |
| } | |
| + (NSString *)stringForBucketedNumber:(int)number | |
| { | |
| if (number < 6) return [NSString stringWithFormat:@"%d", number]; | |
| return @"6+"; | |
| } | |
| + (NSString *)bucket:(float)actualValue andStep:(NSArray *)steps | |
| { | |
| if (nil == steps || steps.count == 0) | |
| { | |
| return @"Unknown"; | |
| } | |
| NSString *bucket; | |
| if (actualValue < [steps[0] integerValue]) | |
| { | |
| bucket = [NSString stringWithFormat:@"less than %d", [steps[0] integerValue]]; | |
| } | |
| else if (actualValue >= [steps[steps.count - 1] integerValue]) | |
| { | |
| bucket = [NSString stringWithFormat:@"more than %d", [steps[steps.count - 1] integerValue]]; | |
| } | |
| else | |
| { | |
| for (int i=0; i < steps.count; i++) | |
| { | |
| if (actualValue < [steps[i] integerValue]) | |
| { | |
| bucket = [NSString stringWithFormat:@"%d-%d", [steps[i - 1] integerValue], [steps[i] integerValue]]; | |
| break; | |
| } | |
| } | |
| } | |
| return bucket; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment