Permalink
Browse files

Removed special integer/double methods, no need for that simple shortcut

  • Loading branch information...
1 parent d32a5bd commit 29d5d3ce1a72f9c35f4dd6b4a5f8a00145a33d2e @myell0w committed Apr 12, 2012
Showing with 8 additions and 41 deletions.
  1. +0 −9 RaptureXML/RXMLElement.h
  2. +0 −24 RaptureXML/RXMLElement.m
  3. +1 −1 Tests/BoundaryTests.m
  4. +2 −2 Tests/DeepChildrenTests.m
  5. +5 −5 Tests/TextConversionTests.m
View
@@ -31,7 +31,6 @@
#import <Foundation/Foundation.h>
#import <libxml/xmlreader.h>
-#import <libxml/xmlmemory.h>
@class RXMLElement;
@@ -45,8 +44,6 @@ typedef void (^RXMLBlock)(RXMLElement *element);
@property (nonatomic, readonly) NSString *text;
@property (nonatomic, readonly) NSString *namespacePrefix;
@property (nonatomic, readonly) NSString *namespaceHref;
-@property (nonatomic, readonly) NSInteger textAsInteger;
-@property (nonatomic, readonly) double textAsDouble;
@property (nonatomic, readonly, getter = isValid) BOOL valid;
+ (id)elementWithString:(NSString *)xmlString encoding:(NSStringEncoding)encoding;
@@ -68,12 +65,6 @@ typedef void (^RXMLBlock)(RXMLElement *element);
- (NSString *)attribute:(NSString *)attributeName;
- (NSString *)attribute:(NSString *)attributeName inNamespace:(NSString *)xmlNamespace;
-- (NSInteger)attributeAsInteger:(NSString *)attributeName;
-- (NSInteger)attributeAsInteger:(NSString *)attributeName inNamespace:(NSString *)xmlNamespace;
-
-- (double)attributeAsDouble:(NSString *)attributeName;
-- (double)attributeAsDouble:(NSString *)attributeName inNamespace:(NSString *)xmlNamespace;
-
- (RXMLElement *)childWithPath:(NSString *)path;
- (RXMLElement *)childWithPath:(NSString *)path inNamespace:(NSString *)xmlNamespace;
View
@@ -260,14 +260,6 @@ - (NSString *)namespaceHref {
return _namespaceHref;
}
-- (NSInteger)textAsInteger {
- return [self.text integerValue];
-}
-
-- (double)textAsDouble {
- return [self.text doubleValue];
-}
-
- (NSString *)attribute:(NSString *)attributeName {
return [self.attributes objectForKey:attributeName];
}
@@ -282,22 +274,6 @@ - (NSString *)attribute:(NSString *)attributeName inNamespace:(NSString *)xmlNam
return nil;
}
-- (NSInteger)attributeAsInteger:(NSString *)attributeName {
- return [[self attribute:attributeName] integerValue];
-}
-
-- (NSInteger)attributeAsInteger:(NSString *)attributeName inNamespace:(NSString *)xmlNamespace {
- return [[self attribute:attributeName inNamespace:xmlNamespace] integerValue];
-}
-
-- (double)attributeAsDouble:(NSString *)attributeName {
- return [[self attribute:attributeName] doubleValue];
-}
-
-- (double)attributeAsDouble:(NSString *)attributeName inNamespace:(NSString *)xmlNamespace {
- return [[self attribute:attributeName inNamespace:xmlNamespace] doubleValue];
-}
-
- (BOOL)isValid {
return _document != nil;
}
View
@@ -54,7 +54,7 @@ - (void)testNamespaceAttribute {
RXMLElement *rxml = [RXMLElement elementWithString:namespaceXML_ encoding:NSUTF8StringEncoding];
STAssertTrue(rxml.isValid, nil);
STAssertEqualObjects([rxml attribute:@"foo" inNamespace:@"*"], @"bar", nil);
- STAssertEquals([rxml attributeAsInteger:@"one" inNamespace:@"*"], 1, nil);
+ STAssertEquals([[rxml attribute:@"one" inNamespace:@"*"] integerValue], 1, nil);
}
- (void)testChild {
@@ -38,7 +38,7 @@ - (void)testDeepChildQuery {
// count the players
RXMLElement *coachingYears = [rxml childWithPath:@"players.coach.experience.years"];
- STAssertEquals(coachingYears.textAsInteger, 1, nil);
+ STAssertEquals([coachingYears.text integerValue], 1, nil);
}
- (void)testDeepChildQueryWithWildcard {
@@ -48,7 +48,7 @@ - (void)testDeepChildQueryWithWildcard {
RXMLElement *coachingYears = [rxml childWithPath:@"players.coach.experience.teams.*"];
// first team returned
- STAssertEquals(coachingYears.textAsInteger, 53, nil);
+ STAssertEquals([coachingYears.text integerValue], 53, nil);
}
- (void)testAllChildren {
@@ -49,9 +49,9 @@ - (void)testIntTags {
[rxml iteratePath:@"*" usingBlock:^(RXMLElement *e) {
if (i == 0) {
- STAssertEquals([e childWithPath:@"id"].textAsInteger, 1, nil);
+ STAssertEquals([[e childWithPath:@"id"].text integerValue], 1, nil);
} else if (i == 1) {
- STAssertEqualsWithAccuracy([e childWithPath:@"id"].textAsDouble, 2.5, 0.01, nil);
+ STAssertEqualsWithAccuracy([[e childWithPath:@"id"].text doubleValue], 2.5, 0.01, nil);
}
i++;
@@ -64,11 +64,11 @@ - (void)testIntAttributes {
[rxml iteratePath:@"*" usingBlock:^(RXMLElement *e) {
if (i == 0) {
- STAssertEquals([e attributeAsInteger:@"id"], 1, nil);
+ STAssertEquals([[e attribute:@"id"] integerValue], 1, nil);
} else if (i == 1) {
- STAssertEqualsWithAccuracy([e attributeAsDouble:@"id"], 2.5, 0.01, nil);
+ STAssertEqualsWithAccuracy([[e attribute:@"id"] doubleValue], 2.5, 0.01, nil);
} else if (i == 2) {
- STAssertEquals([e attributeAsInteger:@"id"], 3, nil);
+ STAssertEquals([[e attribute:@"id"] integerValue], 3, nil);
}
i++;

0 comments on commit 29d5d3c

Please sign in to comment.