Skip to content

Instantly share code, notes, and snippets.

@Watson1978
Forked from seanlilmateus/gist:3029710
Created July 1, 2012 21:48
Show Gist options
  • Save Watson1978/3029741 to your computer and use it in GitHub Desktop.
Save Watson1978/3029741 to your computer and use it in GitHub Desktop.
macruby reject bugs tweets
#!/usr/bin/env macruby -wKU
framework 'Foundation'
## first example reject works great
new_array = ["test", "test 1", "Test 2", "Test 3", 10].reject {|test| test.is_a?(Fixnum) }
p new_array
## second example it still showing tweets with iso_language_code == en
twitter_search = NSURL.URLWithString("http://search.twitter.com/search.json?q=@rubymotion&rpp=100")
data = NSData.dataWithContentsOfURL(twitter_search)
opts = NSJSONReadingMutableContainers | NSJSONWritingPrettyPrinted
json = NSJSONSerialization.JSONObjectWithData(data, options:opts, error:nil)
tweets = json[:results]
tweets = Array.new(tweets)
results = tweets.select { |tweet| tweet.is_a?(Hash) }
.reject { |tweet| tweet[:iso_language_code] == "en" }
.map { |tweet| "%<iso_language_code>s - %<from_user_name>s : %<text>s" % tweet }
puts results
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment