Module: Helpers
- Defined in:
- lib/brewer/helpers.rb
Instance Method Summary collapse
- #adaptibrew_dir(path = "") ⇒ Object
- #brewer_dir(path = "") ⇒ Object
- #clear_screen ⇒ Object
- #confirm(input = gets.chomp) ⇒ Object
- #network? ⇒ Boolean
-
#time ⇒ Object
Formatted as: 03/07/2017 14:26.
- #to_minutes(seconds) ⇒ Object
- #to_seconds(minutes) ⇒ Object
Instance Method Details
#adaptibrew_dir(path = "") ⇒ Object
38 39 40 |
# File 'lib/brewer/helpers.rb', line 38 def adaptibrew_dir(path="") return brewer_dir + "adaptibrew/#{path}" end |
#brewer_dir(path = "") ⇒ Object
34 35 36 |
# File 'lib/brewer/helpers.rb', line 34 def brewer_dir(path="") return Dir.home + "/.brewer/#{path}" end |
#clear_screen ⇒ Object
30 31 32 |
# File 'lib/brewer/helpers.rb', line 30 def clear_screen Gem.win_platform? ? (system "cls") : (system "clear") end |
#confirm(input = gets.chomp) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/brewer/helpers.rb', line 15 def confirm(input=gets.chomp) if input.to_b return true end false end |
#network? ⇒ Boolean
10 11 12 13 |
# File 'lib/brewer/helpers.rb', line 10 def network? connection = Net::Ping::TCP.new('google.com', 80, 5) connection.ping? end |
#time ⇒ Object
Formatted as: 03/07/2017 14:26
6 7 8 |
# File 'lib/brewer/helpers.rb', line 6 def time Time.now.strftime("%m/%d/%Y %H:%M") end |
#to_minutes(seconds) ⇒ Object
22 23 24 |
# File 'lib/brewer/helpers.rb', line 22 def to_minutes(seconds) seconds.to_f / 60 end |
#to_seconds(minutes) ⇒ Object
26 27 28 |
# File 'lib/brewer/helpers.rb', line 26 def to_seconds(minutes) minutes.to_f * 60 end |