Class Array
In: lib/commander/core_ext/array.rb
lib/commander/core_ext/array.rb
Parent: Object

Methods

parse   parse  

Public Class methods

Split string into an array. Used in conjunction with Highline‘s ask, or ask_for_array methods, which must respond to parse.

This method allows escaping of whitespace. For example the arguments foo bar\ baz will become [‘foo’, ‘bar baz’]

Example

  # ask invokes Array#parse
  list = ask 'Favorite cookies:', Array

  # or use ask_for_CLASS
  list = ask_for_array 'Favorite cookies: '

[Source]

    # File lib/commander/core_ext/array.rb, line 21
21:   def self.parse string
22:     eval "%w(#{string})"
23:   end

Split string into an array. Used in conjunction with Highline‘s ask, or ask_for_array methods, which must respond to parse.

This method allows escaping of whitespace. For example the arguments foo bar\ baz will become [‘foo’, ‘bar baz’]

Example

  # ask invokes Array#parse
  list = ask 'Favorite cookies:', Array

  # or use ask_for_CLASS
  list = ask_for_array 'Favorite cookies: '

[Source]

    # File lib/commander/core_ext/array.rb, line 21
21:   def self.parse string
22:     eval "%w(#{string})"
23:   end

[Validate]