Sha256: 008d1f7761a60b4ca8dbfbbafce2fab509f55f4c65de7eb7c937a10667c1ce44
Contents?: true
Size: 1.01 KB
Versions: 1
Compression:
Stored size: 1.01 KB
Contents
module YoutubeDL class Options attr_accessor :store def initialize(options={}) @store = options end def each_paramized @store.each do |key, value| yield(paramize(key), value) end end def each_paramized_key @store.each_key do |key| yield(key, paramize(key)) end end def configure(&block) block.call(self) end def [](key) @store[key.to_sym] end def []=(key, value) @store[key.to_sym] = value end def method_missing(method, *args, &block) if method.to_s.include? '=' method = method.to_s.tr('=', '').to_sym @store[method] = args.first else @store[method] end end def symbolize_keys! @store.keys.each do |key_name| unless key_name.is_a? Symbol @store[key_name.to_sym] = @store[key_name] @store.delete(key_name) end end end private def paramize(key) key.to_s.tr("_", '-') end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
youtube-dl.rb-0.0.1 | lib/youtube-dl/options.rb |