module Yt::Actions::Base
Abstract module that contains methods common to every action
Private Instance Methods
sanitize_brackets!(source)
click to toggle source
@return [Hash] the original hash with angle brackets characters in its
values replaced with similar Unicode characters accepted by Youtube.
@see support.google.com/youtube/answer/57404?hl=en
# File lib/yt/actions/base.rb, line 23 def sanitize_brackets!(source) case source when String then source.gsub('<', '‹').gsub('>', '›') when Array then source.map{|string| sanitize_brackets! string} when Hash then source.each{|k,v| source[k] = sanitize_brackets! v} end end
underscore(value)
click to toggle source
# File lib/yt/actions/base.rb, line 16 def underscore(value) value.to_s.underscore.to_sym end
underscore_keys!(hash)
click to toggle source
If we dropped support for ActiveSupport 3, then we could simply invoke transform_keys!{|key| key.to_s.underscore.to_sym}
# File lib/yt/actions/base.rb, line 12 def underscore_keys!(hash) hash.dup.each_key{|key| hash[underscore key] = hash.delete key} end