Sha256: 74ce712b4df28b50cf301befae48b8b70ed590560ea30c0164578f2c615d3ea9

Contents?: true

Size: 564 Bytes

Versions: 2

Compression:

Stored size: 564 Bytes

Contents

class Array 
  
  ##
  # Split +string+ into an array. Used in
  # conjunction with Highline's ask, or ask_for_array
  # methods, which must respond to #parse.
  #
  # === Highline example
  #  
  #   # ask invokes Array#parse
  #   list = ask 'Favorite cookies:', Array
  #
  #   # or use ask_for_CLASS
  #   list = ask_for_array 'Favorite cookies: '
  #
  
  def self.parse string
    eval "%w(#{string})"
  end
  
  ##
  # Delete switches such as -h or --help. Mutative.
  
  def delete_switches
    self.delete_if { |value| value.to_s =~ /^-/ } 
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
visionmedia-commander-3.2.8 lib/commander/core_ext/array.rb
visionmedia-commander-3.2.9 lib/commander/core_ext/array.rb