Skip to content

Instantly share code, notes, and snippets.

@kei-q
Created June 9, 2012 15:57
Show Gist options
  • Select an option

  • Save kei-q/2901581 to your computer and use it in GitHub Desktop.

Select an option

Save kei-q/2901581 to your computer and use it in GitHub Desktop.
macrubyでtwitter検索のサンプル(twitter gem使用)

元ねた

http://watson1978.github.com/MacRuby-DoJo/blog/2012/03/10/search_tweets/

コードから読みとれない変更点

tableviewの左側のnameをfrom_userに変更しています

gem install

sudo macgem install twitter

備考

macirbではどこかでencodingがASCII-8BITになってしまい使用できなかった xcode上で試していたprojectでrequireして使用したらとくにエラーは表示されなかった

require 'rubygems'
require 'twitter'
class AppDelegate
attr_accessor :window
attr_accessor :textField
attr_accessor :tableView
def initialize()
@search_result = []
end
def numberOfRowsInTableView(aTableView)
@search_result.size
end
def tableView(aTableView, objectValueForTableColumn: aTableColumn, row: rowIndex)
@search_result[rowIndex][aTableColumn.identifier]
end
def search(sender)
query = textField.stringValue
unless query.empty?
@search_result = Twitter.search(query, :rpp => 20)
tableView.reloadData
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment