class NicoQuery::Api::TagSearchRss

Public Class Methods

new(tag: tag, sort: sort, order: order, page: page) click to toggle source
# File lib/nicoquery/api/tag_search_rss.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/nicoquery/api/tag_search_rss.rb, line 33
def format
  "rss=2.0"
end
host() click to toggle source
# File lib/nicoquery/api/tag_search_rss.rb, line 15
def host
  'www.nicovideo.jp'
end
order_param(order) click to toggle source
# File lib/nicoquery/api/tag_search_rss.rb, line 51
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/nicoquery/api/tag_search_rss.rb, line 61
def page_param(page)
  "page=#{page}"
end
params_array(sort, order, page) click to toggle source
# File lib/nicoquery/api/tag_search_rss.rb, line 23
def params_array(sort, order, page)
  [
    sort_param(sort),
    order_param(order),
    page_param(page),
    format,
    "numbers=1", # it enables to catch view/comment/mylist cum.
  ]
end
sort_param(sort) click to toggle source
# File lib/nicoquery/api/tag_search_rss.rb, line 37
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/nicoquery/api/tag_search_rss.rb, line 19
def static_segment
  'tag'
end