Class: Phraseapp::Rest::Query::Base

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id: nil, tags: nil, unverified: nil, excluded: nil, updated_at: nil) ⇒ Base

Returns a new instance of Base.



13
14
15
16
17
18
19
# File 'lib/phraseapp-rest/query/base.rb', line 13

def initialize(id: nil, tags: nil, unverified: nil, excluded: nil, updated_at: nil)
  @id = id
  @tags = tags
  self.unverified = unverified unless unverified.nil?
  self.excluded = excluded unless excluded.nil?
  self.updated_at = updated_at unless updated_at.nil?
end

Instance Attribute Details

#excludedObject

Returns the value of attribute excluded.



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

def excluded
  @excluded
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#tagsObject

Returns the value of attribute tags.



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

def tags
  @tags
end

#unverifiedObject

Returns the value of attribute unverified.



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

def unverified
  @unverified
end

#updated_atObject

Returns the value of attribute updated_at.



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

def updated_at
  @updated_at
end

Instance Method Details

#to_sObject



38
39
40
41
42
43
44
# File 'lib/phraseapp-rest/query/base.rb', line 38

def to_s
  hash = {}
  %w(id tags unverified excluded updated_at).each do |attr|
    hash[attr.to_sym] = URI.encode_www_form_component(send(attr)) unless send(attr).nil?
  end
  'q=' + hash.to_a.map { |x| "#{x[0]}:#{x[1]}" }.join('%20').to_s unless hash.empty?
end