Class: Phraseapp::Rest::Parameter::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/phraseapp-rest/parameter/base.rb

Direct Known Subclasses

Download

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(branch: nil, sort: nil, order: nil) ⇒ Base

Returns a new instance of Base.



10
11
12
13
14
# File 'lib/phraseapp-rest/parameter/base.rb', line 10

def initialize(branch: nil, sort: nil, order: nil)
  @branch = branch unless branch.nil?
  @sort = sort unless sort.nil?
  self.order = order unless order.nil?
end

Instance Attribute Details

#branchObject

Returns the value of attribute branch.



7
8
9
# File 'lib/phraseapp-rest/parameter/base.rb', line 7

def branch
  @branch
end

#orderObject

Returns the value of attribute order.



8
9
10
# File 'lib/phraseapp-rest/parameter/base.rb', line 8

def order
  @order
end

#sortObject

Returns the value of attribute sort.



7
8
9
# File 'lib/phraseapp-rest/parameter/base.rb', line 7

def sort
  @sort
end

Instance Method Details

#to_sObject



23
24
25
26
27
28
29
# File 'lib/phraseapp-rest/parameter/base.rb', line 23

def to_s
  hash = {}
  params.each do |attr|
    hash[attr.to_sym] = send(attr) unless send(attr).nil?
  end
  hash.to_a.map { |x| "#{x[0]}=#{x[1]}" }.join('&').to_s
end