Sha256: a01bfba134594b3f286fe698c533cddb4efcae7870fe22de307b0f8913968306

Contents?: true

Size: 1.28 KB

Versions: 20

Compression:

Stored size: 1.28 KB

Contents

module PortaText
  module Command
    module Api
      # The operators endpoint.
      # https://github.com/PortaText/docs/wiki/REST-API#api_operators
      #
      # Author::    Marcelo Gornstein (mailto:marcelog@portatext.com)
      # Copyright:: Copyright (c) 2015 PortaText
      # License::   Apache-2.0
      class Operators < Base
        def page(page)
          set :page, page
        end

        def sort_by(sort_by, order)
          set :sort_by, sort_by
          set :order, order
        end

        def save_to(file)
          set :accept_file, file
        end

        # rubocop:disable Metrics/MethodLength
        # rubocop:disable Metrics/AbcSize
        def endpoint(_method)
          qs = {}
          unless @args[:page].nil?
            qs['page'] = @args[:page]
            @args.delete :page
          end
          unless @args[:sort_by].nil?
            qs['sort_by'] = @args[:sort_by]
            @args.delete :sort_by
          end
          unless @args[:order].nil?
            qs['order'] = @args[:order]
            @args.delete :order
          end

          return "operators?#{URI.encode_www_form qs}" unless qs.empty?
          'operators'
        end
        # rubocop:enable Metrics/AbcSize
        # rubocop:enable Metrics/MethodLength
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
portatext-1.6.1 lib/portatext/command/api/operators.rb
portatext-1.6.0 lib/portatext/command/api/operators.rb
portatext-1.5.23 lib/portatext/command/api/operators.rb
portatext-1.5.22 lib/portatext/command/api/operators.rb
portatext-1.5.21 lib/portatext/command/api/operators.rb
portatext-1.5.20 lib/portatext/command/api/operators.rb
portatext-1.5.19 lib/portatext/command/api/operators.rb
portatext-1.5.18 lib/portatext/command/api/operators.rb
portatext-1.5.17 lib/portatext/command/api/operators.rb
portatext-1.5.16 lib/portatext/command/api/operators.rb
portatext-1.5.15 lib/portatext/command/api/operators.rb
portatext-1.5.14 lib/portatext/command/api/operators.rb
portatext-1.5.13 lib/portatext/command/api/operators.rb
portatext-1.5.12 lib/portatext/command/api/operators.rb
portatext-1.5.11 lib/portatext/command/api/operators.rb
portatext-1.5.10 lib/portatext/command/api/operators.rb
portatext-1.5.9 lib/portatext/command/api/operators.rb
portatext-1.5.8 lib/portatext/command/api/operators.rb
portatext-1.5.7 lib/portatext/command/api/operators.rb
portatext-1.5.6 lib/portatext/command/api/operators.rb