Fix bugs. Show version in settings. Update icons. Update version.
[pithos-ios] / Classes / Flavor.m
1 //
2 //  Flavor.m
3 //  OpenStack
4 //
5 //  Created by Mike Mayo on 10/1/10.
6 //  The OpenStack project is provided under the Apache 2.0 license.
7 //
8
9 #import "Flavor.h"
10 #import "NSObject+NSCoding.h"
11
12
13 @implementation Flavor
14
15 @synthesize ram, disk;
16
17 #pragma mark - Serialization
18
19 - (void)encodeWithCoder:(NSCoder *)coder {
20     [self autoEncodeWithCoder:coder];
21 }
22
23 - (id)initWithCoder:(NSCoder *)coder {
24     self = [super init];
25     if (self) {
26         [self autoDecode:coder];
27     }
28     return self;
29 }
30
31 - (id)copyWithZone:(NSZone *)zone {
32     Flavor *copy = [[Flavor allocWithZone:zone] init];
33     copy.identifier = self.identifier;
34     copy.ram = self.ram;
35     copy.disk = self.disk;
36     return copy;
37 }
38
39
40 #pragma mark - JSON
41
42 + (Flavor *)fromJSON:(NSDictionary *)dict {
43     Flavor *flavor = [[[Flavor alloc] initWithJSONDict:dict] autorelease];
44     flavor.ram = [[dict objectForKey:@"ram"] intValue];
45     flavor.disk = [[dict objectForKey:@"disk"] intValue];
46     
47     return flavor;
48 }
49
50 #pragma mark - Comparison
51
52 // flavors should be sorted by RAM instead of name
53 - (NSComparisonResult)compare:(Flavor *)aFlavor {
54     return [[NSNumber numberWithInt:self.ram] compare:[NSNumber numberWithInt:aFlavor.ram]];
55 }
56
57
58 @end