Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/wwmd/class_extensions/extensions_base.rb

Direct Known Subclasses

WWMD::FormArray

Instance Method Summary collapse

Instance Method Details

#each_grep(regex) ⇒ Object

grep each element of an array for the passed regular expression and return an Array of matches (only works one deep)



227
228
229
230
231
# File 'lib/wwmd/class_extensions/extensions_base.rb', line 227

def each_grep(regex)
  ret = []
  self.each { |e| ret << e.grep(regex) }
  return ret
end

#to_file(filename) ⇒ Object

join the array with ā€œnā€ and write to a file



234
235
236
# File 'lib/wwmd/class_extensions/extensions_base.rb', line 234

def to_file(filename)
  File.write(filename,self.join("\n"))
end