Created
April 17, 2017 14:25
-
-
Save chabgood/431271af6f29492348201ddf63a1fe0d to your computer and use it in GitHub Desktop.
Find a the count of a word in a file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def find_word(word) | |
the_file="#{Rails.root}/app/models/release_asset.rb" | |
file = File.open(the_file, "r") | |
index = 0 | |
file.each_line { |line| | |
if line.include?(word) | |
index+=1 | |
end | |
} | |
return index | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment