Module: Helpers
- Defined in:
- lib/helpers.rb
Instance Method Summary collapse
- #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
#clear_screen ⇒ Object
30 31 32 |
# File 'lib/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/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/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/helpers.rb', line 6 def time Time.now.strftime("%m/%d/%Y %H:%M") end |
#to_minutes(seconds) ⇒ Object
22 23 24 |
# File 'lib/helpers.rb', line 22 def to_minutes(seconds) seconds.to_f / 60 end |
#to_seconds(minutes) ⇒ Object
26 27 28 |
# File 'lib/helpers.rb', line 26 def to_seconds(minutes) minutes.to_f * 60 end |