Guest User

Untitled

a guest
May 26th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. @contentsArray=[] #first we initialize an array for the contents
  2. @fileArray =[] #then we initialize an array for the files
  3. Dir.foreach("#{RAILS_ROOT}/public/posts") do |fname|
  4. next if fname == '.' or fname == '..'
  5. @fileArray.push fname
  6. end
  7.  
  8. @fileArray = @fileArray.reverse #this insures that the blogs entries are listed in descending order
  9. @fileArray.each{|file|
  10. f = File.open("#{RAILS_ROOT}/public/posts/" + file, 'r')
  11. f.each_line {|line|
  12.  
  13. @contentsArray.push line
  14. }}
Add Comment
Please, Sign In to add comment