Module: Chuckle::Options
- Included in:
- Client
- Defined in:
- lib/chuckle/options.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ cache_dir: nil, cache_errors: true, cookies: false, expires_in: :never, nretries: 2, rate_limit: 1, timeout: 30, user_agent: "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0", verbose: false, }
Instance Method Summary collapse
-
#cache_dir ⇒ Object
cache root directory.
-
#cache_errors? ⇒ Boolean
should errors be cached?.
-
#cookies? ⇒ Boolean
are cookies enabled?.
-
#expires_in ⇒ Object
number of seconds to cache responses and cookies, or :never.
-
#nretries ⇒ Object
number of retries to attempt.
-
#rate_limit ⇒ Object
number of seconds between requests.
-
#timeout ⇒ Object
timeout per retry.
-
#user_agent ⇒ Object
user agent.
-
#verbose? ⇒ Boolean
verbose output?.
Instance Method Details
#cache_dir ⇒ Object
cache root directory
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/chuckle/options.rb', line 16 def cache_dir @cache_dir ||= begin dir = [:cache_dir] dir ||= begin if home = ENV["HOME"] if File.exists?(home) && File.stat(home).writable? "#{home}/.chuckle" end end end dir ||= "/tmp/chuckle" dir end end |
#cache_errors? ⇒ Boolean
should errors be cached?
32 33 34 |
# File 'lib/chuckle/options.rb', line 32 def cache_errors? [:cache_errors] end |
#cookies? ⇒ Boolean
are cookies enabled?
37 38 39 |
# File 'lib/chuckle/options.rb', line 37 def [:cookies] end |
#expires_in ⇒ Object
number of seconds to cache responses and cookies, or :never
42 43 44 |
# File 'lib/chuckle/options.rb', line 42 def expires_in [:expires_in] end |
#nretries ⇒ Object
number of retries to attempt
47 48 49 |
# File 'lib/chuckle/options.rb', line 47 def nretries [:nretries] end |
#rate_limit ⇒ Object
number of seconds between requests
52 53 54 |
# File 'lib/chuckle/options.rb', line 52 def rate_limit [:rate_limit] end |
#timeout ⇒ Object
timeout per retry
57 58 59 |
# File 'lib/chuckle/options.rb', line 57 def timeout [:timeout] end |
#user_agent ⇒ Object
user agent
62 63 64 |
# File 'lib/chuckle/options.rb', line 62 def user_agent [:user_agent] end |
#verbose? ⇒ Boolean
verbose output?
67 68 69 |
# File 'lib/chuckle/options.rb', line 67 def verbose? [:verbose] end |