class Array
History: Stolen wholesale from ActiveSupport.
History: Stolen wholesale from ActiveSupport.
History: Originally called extract_options (no exclamation mark), but written again a few days ago for Switches as peek_options
. extract_options has been moved to extract_options!
as an alias for it.
Public Instance Methods
extract_options!()
click to toggle source
# File lib/Array/extract_optionsX.rb, line 10 def extract_options! last.is_a?(::Hash) ? pop : {} end
peek_options()
click to toggle source
# File lib/Array/peek_options.rb, line 10 def peek_options last.is_a?(::Hash) ? last : {} end
to_csv(quote = :double)
click to toggle source
# File lib/Array/to_csv.rb, line 24 def to_csv(quote = :double) case quote.default_to(:double).to_sym when :double self.collect{|e| '"' + e.to_s + '"'}.join(',') when :spacey_double self.collect{|e| '"' + e.to_s + '"'}.join(', ') when :single self.collect{|e| "'" + e.to_s + "'"}.join(',') when :spacey_single self.collect{|e| "'" + e.to_s + "'"}.join(', ') when :none, :unquoted self.join(',') when :spacey_none, :spacey_unquoted self.join(', ') end end