Class: Array
- Defined in:
- lib/Array/blankQ.rb,
lib/Array/to_csv.rb,
lib/Array/peek_options.rb,
lib/Array/extract_optionsX.rb
Overview
History: Stolen wholesale from ActiveSupport.
Instance Method Summary collapse
Instance Method Details
#extract_options! ⇒ Object
10 11 12 |
# File 'lib/Array/extract_optionsX.rb', line 10 def last.is_a?(::Hash) ? pop : {} end |
#peek_options ⇒ Object
10 11 12 |
# File 'lib/Array/peek_options.rb', line 10 def last.is_a?(::Hash) ? last : {} end |
#to_csv(quote = :double) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# 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 |