class NicoAPI::TagSearch
Public Class Methods
new(tag: tag, sort: sort, order: order, page: page)
click to toggle source
# File lib/nicoapi/tag_search.rb, line 9 def initialize(tag: tag, sort: sort, order: order, page: page) @dynamic_segment = tag @params_array = params_array(sort, order, page) end
Private Instance Methods
format()
click to toggle source
# File lib/nicoapi/tag_search.rb, line 32 def format "rss=2.0" end
host()
click to toggle source
# File lib/nicoapi/tag_search.rb, line 15 def host 'www.nicovideo.jp' end
order_param(order)
click to toggle source
# File lib/nicoapi/tag_search.rb, line 50 def order_param(order) order_string = case order when :asc then 'order=a' when :desc then 'order=d' else nil end order_string.presence || '' end
page_param(page)
click to toggle source
# File lib/nicoapi/tag_search.rb, line 60 def page_param(page) "page=#{page}" end
params_array(sort, order, page)
click to toggle source
# File lib/nicoapi/tag_search.rb, line 23 def params_array(sort, order, page) [ sort_param(sort), order_param(order), page_param(page), format ] end
sort_param(sort)
click to toggle source
# File lib/nicoapi/tag_search.rb, line 36 def sort_param(sort) sort_string = case sort when :commented_at then nil when :view_count then 'v' when :comment_num then 'r' when :mylist_count then 'm' when :published_at then 'f' when :length then 'l' else nil end sort_string.present? ? "sort=#{sort_string}" : '' end
static_segment()
click to toggle source
# File lib/nicoapi/tag_search.rb, line 19 def static_segment 'tag' end