Last active
August 29, 2015 14:11
-
-
Save nguyendangminh/fd3b2793c20f30d29512 to your computer and use it in GitHub Desktop.
Working with file in Ruby
This file contains 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
# Reading whole file | |
bootstrap = File.read('config/bootstrap') | |
# Relative path. | |
# web_app/ | |
# app.rb | |
# db/sample.db | |
# In the app.rb | |
"#{File.expand_path(File.dirname(__FILE__))}/db/sample.db" | |
# Directory listing | |
Dir[File.join(File.dirname(__FILE__), "../lib/collector/handlers/*.rb")].each do |file| | |
require File.join("collector/handlers", File.basename(file, File.extname(file))) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment