Class: NicoQuery::Api::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/nicoquery/api/base.rb

Direct Known Subclasses

GetThumbInfo, MylistRSS, TagSearchRss, VideoArray

Instance Method Summary collapse

Instance Method Details

#getObject



29
30
31
32
33
34
35
36
# File 'lib/nicoquery/api/base.rb', line 29

def get
  RestClient.get uri.to_s do |response, request, result, &block|
    case response.code
    when 200 || 403
      response
    end
  end
end

#paramsObject



12
13
14
# File 'lib/nicoquery/api/base.rb', line 12

def params
  @params_array.join('&')
end

#pathObject



16
17
18
19
20
21
22
# File 'lib/nicoquery/api/base.rb', line 16

def path
  if @dynamic_segment.present?
    static_segment + '/' + @dynamic_segment
  else
    static_segment
  end
end

#schemeObject



8
9
10
# File 'lib/nicoquery/api/base.rb', line 8

def scheme
  'http'
end

#uriObject



24
25
26
27
# File 'lib/nicoquery/api/base.rb', line 24

def uri
  _uri = scheme + "://" + [ ([host, path].join('/')), params].join('?')
  URI.escape _uri
end