Sha256: c83a3dac182b55cf93c3aab419c63be451605180a03640f9edd805d19d8084d0

Contents?: true

Size: 738 Bytes

Versions: 12

Compression:

Stored size: 738 Bytes

Contents

require 'rest_client'
require 'active_support/all'


module NicoQuery
  module Api
    class Base
      attr_reader :forbidden

      def scheme
        'http'
      end

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

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

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

      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
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
nicoquery-0.1.8.11 lib/nicoquery/api/base.rb
nicoquery-0.1.8.10 lib/nicoquery/api/base.rb
nicoquery-0.1.8.9 lib/nicoquery/api/base.rb
nicoquery-0.1.8.8 lib/nicoquery/api/base.rb
nicoquery-0.1.8.7 lib/nicoquery/api/base.rb
nicoquery-0.1.8.6 lib/nicoquery/api/base.rb
nicoquery-0.1.8.5 lib/nicoquery/api/base.rb
nicoquery-0.1.8.4 lib/nicoquery/api/base.rb
nicoquery-0.1.8.3 lib/nicoquery/api/base.rb
nicoquery-0.1.8.2 lib/nicoquery/api/base.rb
nicoquery-0.1.8 lib/nicoquery/api/base.rb
nicoquery-0.1.7 lib/nicoquery/api/base.rb