Skip to content
Newer
Older
100644 62 lines (48 sloc) 1.65 KB
05eedb5 @itod initial add
authored Jan 25, 2010
1 // Copyright 2010 Todd Ditchendorf
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #import <ParseKit/PKLiteral.h>
16 #import <ParseKit/PKToken.h>
17
18 @interface PKLiteral ()
19 @property (nonatomic, retain) PKToken *literal;
20 @end
21
22 @implementation PKLiteral
23
32bd9bf @itod cleaning up factory method return types. adding twitter state test.
authored Apr 7, 2010
24 + (PKLiteral *)literalWithString:(NSString *)s {
05eedb5 @itod initial add
authored Jan 26, 2010
25 return [[[self alloc] initWithString:s] autorelease];
26 }
27
28
29 - (id)initWithString:(NSString *)s {
30 //NSParameterAssert(s);
31 self = [super initWithString:s];
32 if (self) {
33 self.literal = [PKToken tokenWithTokenType:PKTokenTypeWord stringValue:s floatValue:0.0];
34 }
35 return self;
36 }
37
38
39 - (void)dealloc {
40 self.literal = nil;
41 [super dealloc];
42 }
43
44
45 - (BOOL)qualifies:(id)obj {
46 return [literal.stringValue isEqualToString:[obj stringValue]];
47 //return [literal isEqual:obj];
48 }
49
50
51 - (NSString *)description {
52 NSString *className = [NSStringFromClass([self class]) substringFromIndex:2];
53 if ([name length]) {
54 return [NSString stringWithFormat:@"%@ (%@) %@", className, name, literal.stringValue];
55 } else {
56 return [NSString stringWithFormat:@"%@ %@", className, literal.stringValue];
57 }
58 }
59
60 @synthesize literal;
61 @end
Something went wrong with that request. Please try again.