Top Level Namespace
Defined Under Namespace
Modules: Doubapi
Instance Method Summary collapse
Instance Method Details
#test1 ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/test.rb', line 7 def test1 key = "许巍" Doubapi.search_events_of(:key=>key).each do |event| event.what.should be_include(key) puts event.title puts event.when puts event.where puts event.link end end |
#test2 ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/test.rb', line 20 def test2 = "李志" Doubapi.search_albums_of(:singer=>,:since=>"2010-05") do |album| puts "-------------------------------" puts album. puts album.release_date puts album.title puts album.cover_thumbnail puts album.publisher puts album.link puts album.mobile_site end end |
#test4 ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/test.rb', line 80 def test4 totalResults = Doubapi.search_events_of(:key => "all", :location => "shanghai", :start_index => 1,:max_result => 1) do |event| puts "#{event.when} #{event.title}" puts event.where puts event.link puts event.poster_mobile puts event. end puts "totalResults #{totalResults}" end |
#test5 ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/test.rb', line 94 def test5 totalResults ,events = Doubapi.search_events_of(:key => "all", :location => "shanghai", :start_index => 1,:max_result => 5) events.each do |event| puts "#{event.when} #{event.title}" puts event.where puts event.link puts event.poster_mobile puts event. end puts "totalResults #{totalResults}" end |
#test_get_all_events ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/test.rb', line 36 def test_get_all_events puts "trying to get 30 first" batch_size = 30; totalResults1 = Doubapi.search_events_of(:key => "all", :location => "shanghai", :start_index => 1,:max_result => batch_size) do |event| # puts "#{event.when} #{event.title}" end puts "total results #{totalResults1} ,will fetch others" return if(totalResults1 <= batch_size) (2..totalResults1/batch_size).each do |i| start_index = (i-1)*batch_size+1; max_result = batch_size; puts "start_index :#{start_index}" Doubapi.search_events_of(:key => "all", :location => "shanghai", :start_index => start_index, :max_result => max_result) do |event| # puts "#{event.when} #{event.title}" end end return if((totalResults1%batch_size)==0) last_fetch_size = totalResults1 - (totalResults1/batch_size)*batch_size; start_index = (totalResults1/batch_size)*batch_size+1; max_result = last_fetch_size; puts "start_index :#{start_index}" Doubapi.search_events_of(:key => "all", :location => "shanghai", :start_index => start_index, :max_result => max_result) do |event| # puts "#{event.when} #{event.title}" end end |