2017-06-21 06:18:46 +02:00
|
|
|
//
|
|
|
|
// RSOPMLItem.m
|
2017-06-26 01:32:07 +02:00
|
|
|
// RSParser
|
2017-06-21 06:18:46 +02:00
|
|
|
//
|
|
|
|
// Created by Brent Simmons on 2/28/16.
|
|
|
|
// Copyright © 2016 Ranchero Software, LLC. All rights reserved.
|
|
|
|
//
|
|
|
|
|
2017-10-04 22:28:48 +02:00
|
|
|
#import <RSParser/RSOPMLItem.h>
|
|
|
|
#import <RSParser/RSOPMLAttributes.h>
|
|
|
|
#import <RSParser/RSOPMLFeedSpecifier.h>
|
|
|
|
#import <RSParser/RSParserInternal.h>
|
2017-06-21 06:18:46 +02:00
|
|
|
|
|
|
|
|
|
|
|
@interface RSOPMLItem ()
|
|
|
|
|
|
|
|
@property (nonatomic) NSMutableArray *mutableChildren;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
@implementation RSOPMLItem
|
|
|
|
|
|
|
|
@synthesize children = _children;
|
2017-10-08 06:41:21 +02:00
|
|
|
@synthesize feedSpecifier = _feedSpecifier;
|
2017-06-21 06:18:46 +02:00
|
|
|
|
|
|
|
|
|
|
|
- (NSArray *)children {
|
|
|
|
|
|
|
|
return [self.mutableChildren copy];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)setChildren:(NSArray *)children {
|
|
|
|
|
|
|
|
_children = children;
|
|
|
|
self.mutableChildren = [_children mutableCopy];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)addChild:(RSOPMLItem *)child {
|
|
|
|
|
|
|
|
if (!self.mutableChildren) {
|
|
|
|
self.mutableChildren = [NSMutableArray new];
|
|
|
|
}
|
|
|
|
|
|
|
|
[self.mutableChildren addObject:child];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-10-08 06:41:21 +02:00
|
|
|
- (RSOPMLFeedSpecifier *)feedSpecifier {
|
2017-06-21 06:18:46 +02:00
|
|
|
|
2017-10-08 06:41:21 +02:00
|
|
|
if (_feedSpecifier) {
|
|
|
|
return _feedSpecifier;
|
2017-06-21 06:18:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
NSString *feedURL = self.attributes.opml_xmlUrl;
|
2017-06-25 23:06:01 +02:00
|
|
|
if (RSParserObjectIsEmpty(feedURL)) {
|
2017-06-21 06:18:46 +02:00
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2017-10-08 06:41:21 +02:00
|
|
|
_feedSpecifier = [[RSOPMLFeedSpecifier alloc] initWithTitle:self.attributes.opml_title feedDescription:self.attributes.opml_description homePageURL:self.attributes.opml_htmlUrl feedURL:feedURL];
|
2017-06-21 06:18:46 +02:00
|
|
|
|
2017-10-08 06:41:21 +02:00
|
|
|
return _feedSpecifier;
|
2017-06-21 06:18:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *)titleFromAttributes {
|
|
|
|
|
|
|
|
NSString *title = self.attributes.opml_title;
|
|
|
|
if (title) {
|
|
|
|
return title;
|
|
|
|
}
|
|
|
|
title = self.attributes.opml_text;
|
|
|
|
if (title) {
|
|
|
|
return title;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)isFolder {
|
|
|
|
|
|
|
|
return self.mutableChildren.count > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|