Class: Switcher
- Inherits:
-
Object
- Object
- Switcher
- Defined in:
- lib/env_switch/switcher.rb
Instance Method Summary collapse
-
#initialize(env_filename) ⇒ Switcher
constructor
A new instance of Switcher.
- #switch ⇒ Object
Constructor Details
#initialize(env_filename) ⇒ Switcher
Returns a new instance of Switcher.
2 3 4 |
# File 'lib/env_switch/switcher.rb', line 2 def initialize(env_filename) @env_filename = env_filename end |
Instance Method Details
#switch ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/env_switch/switcher.rb', line 6 def switch files = Dir.glob("*.env") result = files.select { |f| f == "#{@env_filename}.env" } if !result.empty? FileUtils.cp(result.first, '.env') puts "Copied #{result.first} to .env" else puts "No env found for #{@env_filename}" end end |