Sha256: 2e263995bb4266a0f111dcb59775224680416f4e63b4624aa63b66d2ff09c39a

Contents?: true

Size: 706 Bytes

Versions: 5

Compression:

Stored size: 706 Bytes

Contents

require 'rest_client'
require 'active_support/all'


module NicoQuery
  module Api
    class Base
      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
        RestClient.get uri.to_s do |response, request, result, &block|
          case response.code
          when 200 || 403
            response
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
nicoquery-0.1.4 lib/nicoquery/api/base.rb
nicoquery-0.1.3 lib/nicoquery/api/base.rb
nicoquery-0.1.2 lib/nicoquery/api/base.rb
nicoquery-0.1.1 lib/nicoquery/api/base.rb
nicoquery-0.1.0 lib/nicoquery/api/base.rb