Skip to content

Instantly share code, notes, and snippets.

@chabgood
Created April 17, 2017 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chabgood/431271af6f29492348201ddf63a1fe0d to your computer and use it in GitHub Desktop.
Save chabgood/431271af6f29492348201ddf63a1fe0d to your computer and use it in GitHub Desktop.
Find a the count of a word in a file
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