Class: TwicasStream::Search::SearchUsers

Inherits:
Object
  • Object
show all
Defined in:
lib/twicas_stream/search.rb

Constant Summary collapse

PREFIX_URL =

:users => [ { :id => “182224938”, :screen_id => “twitcasting_jp”, :name => “ツイキャス公式”, :image => “”, :profile => “ツイキャスの公式アカウントです。ツイキャスに関するお知らせなどを投稿します。なお、お問い合わせは t.co/4gCf7XVm7N までお願いします。公式Facebookページt.co/bxYVwpzTJBn公式Instagramnt.co/Bm2O2J2Kfs”, :level => 24, :last_movie_id => “189037369”, :is_live => true, :supporter_count => 0, :supporting_count => 0, :created => 0 }, { :id => “2880417757”, :screen_id => “twitcasting_pr”, :name => “ツイキャス運営事務局”, :image => “”, :profile => “モイ! ツイキャスを運営しているモイ株式会社広報担当のアカウントです。公式アカウントはこちら! @twitcasting_jp”, :level => 24, :last_movie_id => “323387579”, :is_live => false, :supporter_count => 0, :supporting_count => 0, :created => 0 }, : : ] }

'search'
SUFFIX_URL =
'users'
DEFAULT_LIMIT =
10
LOWER_LIMIT =
1
UPPER_LIMIT =
50
LANG_LIMITATION =
['ja']

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(words, limit = DEFAULT_LIMIT, lang) ⇒ SearchUsers

Returns a new instance of SearchUsers.



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/twicas_stream/search.rb', line 56

def initialize words, limit = DEFAULT_LIMIT, lang
	@response = Hash.new
	param = Hash.new

	if words.empty?
		STDERR.puts "#{__FILE__}:#{__LINE__}:Warning: no word."
	end

	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 LANG_LIMITATION.include?(lang)
		STDERR.puts "#{__FILE__}:#{__LINE__}:Warning: out of limitation. currently support language is '#{LANG_LIMITATION.join("', '")}' only."
	end

	param['words'] = words.split(' ').join('+')
	param['limit'] = limit
	param['lang'] = lang

	url = [BASE_URL, PREFIX_URL, SUFFIX_URL].join('/') + TwicasStream.make_query_string(param)
	# => 'https://apiv2.twitcasting.tv/search/users?words=ツイキャス+公式&limit=10&lang=ja'

	@response = TwicasStream.parse(TwicasStream.get(url))
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



10
11
12
# File 'lib/twicas_stream/search.rb', line 10

def response
  @response
end