/ObjectiveCRuby

Ruby-ish methods implemented in Objetive-C

Primary LanguageObjective-C

Ruby-ish methods for Objective-C

##Intro This is a project for personal development to learn more about Objective-C and Ruby.

##Tests Tests are provided through Expecta, and are largely reproduced from the Ruby Reference page, some methods may be changed slightly in how they function, but for the most part the goal is to ape Ruby behaviour.

##Examples

####Loop five times

[@5 rby_times:^(NSInteger idx) {
  NSLog(@"%d", idx);
}];

result

1
2
3
4
5

####Group by

NSArray *array = @[ @1, @2, @3, @4, @5, @6 ];

NSDictionary *result = [array rby_groupBy:^(NSNumber *object) {
  return @([object integerValue] % 3);
}];

result

@{
  @0 : @[ @3, @6 ],
  @1 : @[ @1, @4 ],
  @2 : @[ @2, @5 ],
}

##Current Implemented Methods

###NSArray+Ruby

#map
#group_by
#inject
#min
#max
#min_by
#max_by
#none
#one
#partition
#reject
#plus
#times
#union
#intersect
#compact
#cycle
#transpose
#unique
#rotate
#push
#pop

###NSNumber+Ruby

#abs
#ceil
#floor
#imaginary
#times

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Improvements

Unit tests for NSArray which need writing:

#one  
#partition  
#reject
#plus
#plus
#times
#union
#intersect
#compact
#cycle
#transpose
#unique
#rotate
#push
#pop