Class: CurlWrapper

Inherits:
Object
  • Object
show all
Includes:
ConfigOptions
Defined in:
lib/curl_wrapper.rb,
lib/curl_wrapper/version.rb,
lib/curl_wrapper/config_options.rb

Defined Under Namespace

Modules: ConfigOptions

Constant Summary collapse

VERSION =
"0.0.3"

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ConfigOptions

#append_option, #fail, #http1_0, #method_missing, #options, #p, #proxy1_0, #verbose

Constructor Details

#initialize {|_self| ... } ⇒ CurlWrapper

Returns a new instance of CurlWrapper.

Yields:

  • (_self)

Yield Parameters:

  • _self (CurlWrapper)

    the object that the method was called on



14
15
16
# File 'lib/curl_wrapper.rb', line 14

def initialize(&block)
  yield self if block_given?
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class CurlWrapper::ConfigOptions

Class Method Details

.method_missing(method, *args, &block) ⇒ Object



9
10
11
# File 'lib/curl_wrapper.rb', line 9

def method_missing(method, *args, &block)
  new.send(method, *args, &block)
end

Instance Method Details

#commandObject



18
19
20
# File 'lib/curl_wrapper.rb', line 18

def command
  ['curl', options].join(' ')
end

#errObject



34
35
36
37
# File 'lib/curl_wrapper.rb', line 34

def err
  run if @stdout.nil?
  @stderr.collect(&:to_s).join('')
end

#outObject Also known as: body, to_s



26
27
28
29
# File 'lib/curl_wrapper.rb', line 26

def out
  run if @stdout.nil?
  @stdout.collect(&:to_s).join('')
end

#runObject



22
23
24
# File 'lib/curl_wrapper.rb', line 22

def run
  @stdin, @stdout, @stderr, @wait_thr = Open3.popen3(command)
end

#to_aryObject



39
40
41
# File 'lib/curl_wrapper.rb', line 39

def to_ary
  [to_s]
end