moduleEthonmoduleEasies# This module contains the logic and knowledge about the# available options on easy.moduleOptions# :nodoc:defself.included(base)base.extendClassMethodsbase.const_set(:AVAILABLE_OPTIONS,[:dns_cache_timeout,:httppost,:put,:httpget,:nobody,:upload,:customrequest,:cainfo,:capath,:connecttimeout,:followlocation,:httpauth,:infilesize,:interface,:maxredirs,:nosignal,:postfieldsize,:copypostfields,:proxy,:proxyauth,:proxytype,:timeout,:readdata,:sslcert,:ssl_verifypeer,:ssl_verifyhost,:sslcerttype,:sslkey,:sslkeytype,:sslversion,:url,:useragent,:userpwd,:verbose,:readfunction])base.send(:attr_accessor,*Ethon::Easy::AVAILABLE_OPTIONS)endmoduleClassMethods# :nodoc:# Return the available options.## @example Return the available options.# easy.available_options## @return [ Array ] The available options.defavailable_optionsEthon::Easy::AVAILABLE_OPTIONSend# Return the options which need to set as 0 or 1 for easy.## @example Return the bool options.# easy.bool_options## @return [ Array ] The bool options.defbool_options[:followlocation,:nosignal,:ssl_verifypeer,:verbose,:httpget,:nobody,:upload]end# Return the options which are an enum for easy.## @example Return the enum options.# easy.enum_options## @return [ Hash ] The enum options.defenum_options{:httpauth=>Curl::Auth}end# Return the options which need to set as an integer for easy.## @example Return the int options.# easy.int_options## @return [ Array ] The int options.defint_options[:connecttimeout,:dns_cache_timeout,:infilesize,:maxredirs,:postfieldsize,:ssl_verifyhost,:timeout]endend# Set specified options on easy handle.## @example Set options.# easy.set_optionsdefset_optionsself.class.available_options.eachdo|option|value=value_for(option)nextifvalue.nil?Curl.set_option(option,value,handle)endend# Return the value to set to easy handle. It is converted with the help# of bool_options, enum_options and int_options.## @example Return casted the value.# easy.value_for(:verbose)## @return [ Object ] The casted value.defvalue_for(option)value=method(option).callreturnnilifvalue.nil?ifself.class.bool_options.include?(option)value?1:0elsifself.class.enum_options.key?(option)self.class.enum_options[option][value]elsifself.class.int_options.include?(option)value.to_ielsifvalue.is_a?(::String)Util.escape_zero_byte(value)elsevalueendendendendend