Joined February 2012
·

Joseph Jaber

SciMed Solutions
·
Durham, NC
·
·
·

Rebound:

module WordSearch
  def self.files_for(path, *words)
    files(path).each do |file, lines|
      File.open(file, 'r').each_line.with_index do |line, i|
        words.each do |word|
          puts "#{file}:#{i}:#{word}" if line.include?(word)
        end
      end
    end
  end

  def self.files(search_path='')
    search_path << "**/*.*"
    Dir[search_path].reject { |f| f == __FILE__ }
  end
end

WordSearch.files_for('/Desktop/', 'word1', "word2")

@idered Thanks for sharing the tip. As a side comment, I thought it would be worthwhile to note the example of image tags that display non-content visual aids (loaders and such) are counteractive to the distinction drawn between CSS (the visual style of the document) and HTML (the data structure of the document).

The <img> tag has the meaning, "This picture is consumable content that is relevant to the page." e.g. a photograph in a news article is a relevant and impactful piece of data that is related to the rest of the article. In this case the loader is not a relevant or impactful part of the actual content on the page, it is a user interface helper for those who aren't visually impaired.

That said, if semantics are a priority for any future reader, It might be slightly more semantic to have loaders be faceless <div class='loader'> tags with background images.

Outside of that, thanks again for sharing the tip -- I believe you are using the hidden attribute correctly in your use case.

Good tip.

Also it's worth noting that In Rubygems 2.0.0+ --no-document will be an alternative to --no-ri/--no-rdoc

Achievements
142 Karma
6,487 Total ProTip Views