forked from lpa/viewcumber
/
Email.j
60 lines (50 loc) · 1.14 KB
/
Email.j
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
@import <Foundation/CPObject.j>
@implementation Email : CPObject
{
CPArray to;
CPArray from;
CPString subject @accessors;
CPString htmlFilename;
CPString textFilename;
CPString _fromStringValue;
CPString _toStringValue;
}
+ (CPArray)emailsFromCucumberJSON:(Object)json
{
var emails = [CPArray arrayWithArray:[]];
for(var i = 0; i < json.length; i++) {
[emails addObject:[[Email alloc] initWithCucumberJSON:json[i]]];
}
return emails;
}
- (id)initWithCucumberJSON:(Object)json
{
self = [super init];
if(self) {
to = [CPArray arrayWithArray:json.to];
from = [CPArray arrayWithArray:json.from];
subject = json.subject;
htmlFilename = json.body.html;
textFilename = json.body.text;
}
return self;
}
- (CPString)fromStringValue
{
if(!_fromStringValue) {
_fromStringValue = [to componentsJoinedByString:@", "];
}
return _fromStringValue;
}
- (CPString)toStringValue
{
if(!_toStringValue) {
_toStringValue = [to componentsJoinedByString:@", "];
}
return _toStringValue;
}
- (CPString)htmlURL
{
return [[AppController resultsDirURL] stringByAppendingString:htmlFilename];
}
@end