Class: TwicasStream::Category::GetCategories

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

Constant Summary collapse

PREFIX_URL =

:categories => [ { :id => “_channel”, :name => “チャンネル”, :sub_categories => [ => “_system_channel_5”, :name => “ミュージックch”, :count => 100, => “_system_channel_6”, :name => “ママch”, :count => 49, => “_system_channel_7”, :name => “アニメch”, :count => 42 ] }, { :id => “girls_jp”, :name => “女子CAS”, :sub_categories => [ => “girls_face_jp”, :name => “女子:顔出し”, :count => 66, => “girls_jcjk_jp”, :name => “女子:JCJK”, :count => 17, => “girls_ljk_jp”, :name => “女子:LJK”, :count => 89 ] } ] }

'categories'
LANG_LIMITATION =
['ja', 'en']

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lang) ⇒ GetCategories

Returns a new instance of GetCategories.



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/twicas_stream/category.rb', line 37

def initialize lang
	@response = Hash.new
	param = Hash.new

	unless LANG_LIMITATION.include?(lang)
		STDERR.puts "#{__FILE__}:#{__LINE__}:Warning: out of limitation. currently support language are '#{LANG_LIMITATION.join("' or '")}'."
	end

	param['lang'] = lang

	url = [BASE_URL, PREFIX_URL].join('/') + TwicasStream.make_query_string(param)
	# => 'https://apiv2.twitcasting.tv/categories?lang=ja'

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

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



9
10
11
# File 'lib/twicas_stream/category.rb', line 9

def response
  @response
end