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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/test.rb', line 20 def test2 #author = "李志" = "窦唯" total, albums = Doubapi.search_albums_of(:singer=>,:since=>"1900-05",:max_result => 20) #release date decending albums.sort {|a , b| b.release_date <=> a.release_date }.each 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 puts album. album.tracks.each do |track| puts track.title end end #rating decending #release date decending albums.sort {|a , b| b. <=> a. }.each 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 puts album. end puts "total #{total}" end |
#test4 ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/test.rb', line 105 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
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/test.rb', line 119 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
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/test.rb', line 61 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 |