Class: PortaText::Command::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/portatext/command/base.rb

Overview

The base command class.

Author

Marcelo Gornstein ([email protected])

Copyright

Copyright © 2015 PortaText

License

Apache-2.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



57
58
59
# File 'lib/portatext/command/base.rb', line 57

def initialize
  @args = {}
end

Instance Attribute Details

#client=(value) ⇒ Object (writeonly)

Sets the attribute client

Parameters:

  • value

    the value to set the attribute client to.



11
12
13
# File 'lib/portatext/command/base.rb', line 11

def client=(value)
  @client = value
end

Instance Method Details

#accept_content_type(_method) ⇒ Object



44
45
46
47
48
49
# File 'lib/portatext/command/base.rb', line 44

def accept_content_type(_method)
  return '*/*' unless @args[:accept_any_file].nil?
  return 'text/csv' unless @args[:accept_file].nil?
  return 'audio/mpeg' unless @args[:accept_sound_file].nil?
  'application/json'
end

#body(_method) ⇒ Object



51
52
53
54
55
# File 'lib/portatext/command/base.rb', line 51

def body(_method)
  return "file:#{@args[:file]}" unless @args[:file].nil?
  return '' if @args.size.eql? 0
  @args.to_json
end

#content_type(_method) ⇒ Object



38
39
40
41
42
# File 'lib/portatext/command/base.rb', line 38

def content_type(_method)
  return 'text/csv' unless @args[:file].nil?
  return 'audio/mpeg' unless @args[:sound_file].nil?
  'application/json'
end

#deleteObject



29
30
31
# File 'lib/portatext/command/base.rb', line 29

def delete
  run :delete
end

#getObject



13
14
15
# File 'lib/portatext/command/base.rb', line 13

def get
  run :get
end

#patchObject



25
26
27
# File 'lib/portatext/command/base.rb', line 25

def patch
  run :patch
end

#postObject



17
18
19
# File 'lib/portatext/command/base.rb', line 17

def post
  run :post
end

#putObject



21
22
23
# File 'lib/portatext/command/base.rb', line 21

def put
  run :put
end

#set(key, value) ⇒ Object



33
34
35
36
# File 'lib/portatext/command/base.rb', line 33

def set(key, value)
  @args[key] = value
  self
end