Module: YoudaoFanyiAPI::Configuration

Included in:
YoudaoFanyiAPI
Defined in:
lib/youdao_fanyi_api/configuration.rb

Constant Summary

VALID_OPTIONS =
key keyfrom].freeze
DEFAULT_OPTIONS =
type doctype version].freeze
OPTIONS =
VALID_OPTIONS + DEFAULT_OPTIONS
DEFAULT_TYPE =
'data'
DEFAULT_DOCTYPE =
'json'
DEFAULT_VERSION =
'1.1'

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) extended(base)



12
13
14
# File 'lib/youdao_fanyi_api/configuration.rb', line 12

def self.extended(base)
  base.reset
end

Instance Method Details

- (Object) configure {|_self| ... }

Yields:

  • (_self)

Yield Parameters:



24
25
26
# File 'lib/youdao_fanyi_api/configuration.rb', line 24

def configure
  yield self
end

- (Object) options



28
29
30
# File 'lib/youdao_fanyi_api/configuration.rb', line 28

def options
  OPTIONS.collect { |key| [key, send(key)] }.to_h
end

- (Object) reset



16
17
18
19
20
21
22
# File 'lib/youdao_fanyi_api/configuration.rb', line 16

def reset
  self.key     = nil
  self.keyfrom = nil
  self.type    = DEFAULT_TYPE
  self.doctype = DEFAULT_DOCTYPE
  self.version = DEFAULT_VERSION
end