Class: TwicasStream::Search::SearchLiveMovies
- Inherits:
-
Object
- Object
- TwicasStream::Search::SearchLiveMovies
- Defined in:
- lib/twicas_stream/search.rb
Constant Summary collapse
- PREFIX_URL =
:movies => [ { :movie => { :id => “189037369”, :user_id => “182224938”, :title => “ライブ #189037369”, : : }, :broadcaster => { :id => “182224938”, :screen_id => “twitcasting_jp”, :name => “ツイキャス公式”, : : }, :tags => [“人気”, “コンティニュー中”, “レベル40+”, “初見さん大歓迎”, “まったり”, “雑談”] }, { :movie => { :id => “323387579”, :user_id => “2880417757”, :title => “ライブ #323387579”, : : }, :broadcaster => { :id => “2880417757”, :screen_id => “twitcasting_pr”, :name => “ツイキャス運営事務局”, : : }, :tags => [“人気”, “コンティニュー中”, “レベル40+”, “初見さん大歓迎”, “まったり”, “雑談”] }, : : ] }
'search'
- SUFFIX_URL =
'lives'
- DEFAULT_LIMIT =
10
- LOWER_LIMIT =
1
- UPPER_LIMIT =
100
- TYPE_LIMITATION =
TYPE_LIMITATION = [‘tag’, ‘word’, ‘category’, ‘new’, ‘recommend’]
['recommend']
- LANG_LIMITATION =
['ja']
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
-
#initialize(limit = DEFAULT_LIMIT, type, context, lang) ⇒ SearchLiveMovies
constructor
A new instance of SearchLiveMovies.
Constructor Details
#initialize(limit = DEFAULT_LIMIT, type, context, lang) ⇒ SearchLiveMovies
Returns a new instance of SearchLiveMovies.
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/twicas_stream/search.rb', line 141 def initialize limit = DEFAULT_LIMIT, type, context, lang @response = Hash.new param = Hash.new unless limit >= LOWER_LIMIT and limit <= UPPER_LIMIT STDERR.puts "#{__FILE__}:#{__LINE__}:Warning: out of limitation. limit range is #{LOWER_LIMIT} ~ #{UPPER_LIMIT}" end unless TYPE_LIMITATION.include?(type) STDERR.puts "#{__FILE__}:#{__LINE__}:Warning: out of limitation. support types is '#{TYPE_LIMITATION.join("', '")}' only." end unless LANG_LIMITATION.include?(lang) STDERR.puts "#{__FILE__}:#{__LINE__}:Warning: out of limitation. currently support language is '#{LANG_LIMITATION.join("', '")}' only." end param['limit'] = limit param['type'] = type =begin if type == 'tag' or type == 'word' param['context'] = context.split(' ').join('+') elsif type == 'category' param['context'] = context #else # => tag is 'new' or 'recommend', then don't need 'context' end =end param['lang'] = lang url = [BASE_URL, PREFIX_URL, SUFFIX_URL].join('/') + TwicasStream.make_query_string(param) # => 'https://apiv2.twitcasting.tv/search/lives?limit=10&type=recommend&lang=ja' @response = TwicasStream.parse(TwicasStream.get(url)) end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
84 85 86 |
# File 'lib/twicas_stream/search.rb', line 84 def response @response end |