Class: Array
Class Method Summary collapse
-
.parse(string) ⇒ Object
Split
string
into an array.
Instance Method Summary collapse
-
#delete_switches ⇒ Object
Delete switches such as -h or –help.
Class Method Details
.parse(string) ⇒ Object
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: '
18 19 20 |
# File 'lib/commander/core_ext/array.rb', line 18 def self.parse string eval "%w(#{string})" end |
Instance Method Details
#delete_switches ⇒ Object
Delete switches such as -h or –help. Mutative.
25 26 27 |
# File 'lib/commander/core_ext/array.rb', line 25 def delete_switches self.delete_if { |value| value.to_s =~ /^-/ } end |