/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. // GDataYouTubeRating.m
  17. //
  18. #if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_YOUTUBE_SERVICE
  19. #import "GDataYouTubeRating.h"
  20. #import "GDataYouTubeConstants.h"
  21. static NSString* const kValueAttr = @"value";
  22. static NSString* const kNumLikesAttr = @"numLikes";
  23. static NSString* const kNumDislikesAttr = @"numDislikes";
  24. @implementation GDataYouTubeRating
  25. // <yt:rating numDislikes='28' numLikes='143'/>
  26. // or
  27. // <yt:rating value="like"/>
  28. + (NSString *)extensionElementURI { return kGDataNamespaceYouTube; }
  29. + (NSString *)extensionElementPrefix { return kGDataNamespaceYouTubePrefix; }
  30. + (NSString *)extensionElementLocalName { return @"rating"; }
  31. + (GDataYouTubeRating *)ratingWithValue:(NSString *)str {
  32. GDataYouTubeRating *obj = [self object];
  33. [obj setValue:str];
  34. return obj;
  35. }
  36. - (void)addParseDeclarations {
  37. NSArray *attrs = [NSArray arrayWithObjects:
  38. kValueAttr, kNumLikesAttr, kNumDislikesAttr, nil];
  39. [self addLocalAttributeDeclarations:attrs];
  40. }
  41. #pragma mark -
  42. - (NSString *)value {
  43. return [self stringValueForAttribute:kValueAttr];
  44. }
  45. - (void)setValue:(NSString *)str {
  46. [self setStringValue:str forAttribute:kValueAttr];
  47. }
  48. - (NSNumber *)numberOfLikes {
  49. return [self intNumberForAttribute:kNumLikesAttr];
  50. }
  51. - (void)setNumberOfLikes:(NSNumber *)num {
  52. [self setStringValue:[num stringValue] forAttribute:kNumLikesAttr];
  53. }
  54. - (NSNumber *)numberOfDislikes {
  55. return [self intNumberForAttribute:kNumDislikesAttr];
  56. }
  57. - (void)setNumberOfDislikes:(NSNumber *)num {
  58. [self setStringValue:[num stringValue] forAttribute:kNumDislikesAttr];
  59. }
  60. @end
  61. #endif // !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_YOUTUBE_SERVICE