Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/conductor/array.rb
Overview
Array helpers
Instance Method Summary collapse
-
#includes_file?(filename) ⇒ Boolean
Test if any path in array matches filename.
-
#includes_frag?(frag) ⇒ Boolean
Test if any path in an array contains any matching fragment.
-
#shell_join ⇒ Array
Join components within an array.
-
#symbolize_keys ⇒ Array
Symbolize the keys of an array of hashes.
-
#symbolize_keys! ⇒ Array
Destructive version of #symbolize_keys.
Instance Method Details
#includes_file?(filename) ⇒ Boolean
Test if any path in array matches filename
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/conductor/array.rb', line 41 def includes_file?(filename) inc = false each do |path| path = path.join if path.is_a?(Array) if path =~ /#{Regexp.escape(filename)}$/i inc = true break end end inc end |
#includes_frag?(frag) ⇒ Boolean
Test if any path in an array contains any matching fragment
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/conductor/array.rb', line 60 def includes_frag?(frag) inc = false each do |path| path = path.join if path.is_a?(Array) if path =~ /#{Regexp.escape(frag)}/i inc = true break end end inc end |
#shell_join ⇒ Array
Join components within an array
30 31 32 |
# File 'lib/conductor/array.rb', line 30 def shell_join map { |p| Shellwords.join(p) } end |
#symbolize_keys ⇒ Array
Symbolize the keys of an array of hashes
21 22 23 |
# File 'lib/conductor/array.rb', line 21 def symbolize_keys map { |h| h.symbolize_keys } end |
#symbolize_keys! ⇒ Array
Destructive version of #symbolize_keys
12 13 14 |
# File 'lib/conductor/array.rb', line 12 def symbolize_keys! replace symbolize_keys end |