PageRenderTime 48ms CodeModel.GetById 11ms app.highlight 33ms RepoModel.GetById 2ms app.codeStats 0ms

/Source/externals/GData/Source/Clients/YouTube/GDataYouTubeRating.m

http://google-email-uploader-mac.googlecode.com/
Objective C | 78 lines | 41 code | 17 blank | 20 comment | 1 complexity | bac4f4c6498ef4e70ced2d4e688879d2 MD5 | raw file
 1/* Copyright (c) 2010 Google Inc.
 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
16//
17//  GDataYouTubeRating.m
18//
19
20#if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_YOUTUBE_SERVICE
21
22#import "GDataYouTubeRating.h"
23#import "GDataYouTubeConstants.h"
24
25static NSString* const kValueAttr       = @"value";
26static NSString* const kNumLikesAttr    = @"numLikes";
27static NSString* const kNumDislikesAttr = @"numDislikes";
28
29@implementation GDataYouTubeRating
30// <yt:rating numDislikes='28' numLikes='143'/>
31// or
32// <yt:rating value="like"/>
33
34+ (NSString *)extensionElementURI       { return kGDataNamespaceYouTube; }
35+ (NSString *)extensionElementPrefix    { return kGDataNamespaceYouTubePrefix; }
36+ (NSString *)extensionElementLocalName { return @"rating"; }
37
38+ (GDataYouTubeRating *)ratingWithValue:(NSString *)str {
39  GDataYouTubeRating *obj = [self object];
40  [obj setValue:str];
41  return obj;
42}
43
44- (void)addParseDeclarations {
45  NSArray *attrs = [NSArray arrayWithObjects:
46                    kValueAttr, kNumLikesAttr, kNumDislikesAttr, nil];
47
48  [self addLocalAttributeDeclarations:attrs];
49}
50
51#pragma mark -
52
53- (NSString *)value {
54  return [self stringValueForAttribute:kValueAttr];
55}
56
57- (void)setValue:(NSString *)str {
58  [self setStringValue:str forAttribute:kValueAttr];
59}
60
61- (NSNumber *)numberOfLikes {
62  return [self intNumberForAttribute:kNumLikesAttr];
63}
64
65- (void)setNumberOfLikes:(NSNumber *)num {
66  [self setStringValue:[num stringValue] forAttribute:kNumLikesAttr];
67}
68
69- (NSNumber *)numberOfDislikes {
70  return [self intNumberForAttribute:kNumDislikesAttr];
71}
72
73- (void)setNumberOfDislikes:(NSNumber *)num {
74  [self setStringValue:[num stringValue] forAttribute:kNumDislikesAttr];
75}
76@end
77
78#endif // !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_YOUTUBE_SERVICE