Sha256: 5ab86a3f22cf35f458c067cb8882d51ec3b1e028e43b60c64fd947821ac86cc6
Contents?: true
Size: 784 Bytes
Versions: 2
Compression:
Stored size: 784 Bytes
Contents
module Wikipedia class Configuration DEFAULT = { protocol: 'https', domain: 'en.wikipedia.org', path: 'w/api.php', user_agent: 'wikipedia-client/1.7 (https://github.com/kenpratt/wikipedia-client)', headers: {} }.freeze def initialize(configuration = DEFAULT) DEFAULT.merge(configuration).each { |args| send(*args) } end def [](directive) send(directive) end def self.directives(*directives) directives.each do |directive| define_method directive do |*args| return instance_variable_get("@#{directive}") if args.empty? instance_variable_set("@#{directive}", args.first) end end end directives :protocol, :domain, :path, :user_agent, :headers end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
wikipedia-client-1.17.0 | lib/wikipedia/configuration.rb |
wikipedia-client-1.16.0 | lib/wikipedia/configuration.rb |