Class: NicoQuery::Api::Base

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

Direct Known Subclasses

GetThumbInfo, MylistRSS, TagSearchRss, VideoArray

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#forbiddenObject (readonly)

Returns the value of attribute forbidden.



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

def forbidden
  @forbidden
end

Instance Method Details

#getObject



31
32
33
34
35
36
37
38
39
# File 'lib/nicoquery/api/base.rb', line 31

def get
  res = nil

  RestClient.get uri.to_s do |response|
    res = response
  end

  { body: res.to_s, headers: res.headers, status_code: res.code }
end

#paramsObject



14
15
16
# File 'lib/nicoquery/api/base.rb', line 14

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

#pathObject



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

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

#schemeObject



10
11
12
# File 'lib/nicoquery/api/base.rb', line 10

def scheme
  'http'
end

#uriObject



26
27
28
29
# File 'lib/nicoquery/api/base.rb', line 26

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