Class: LetsCert::Runner::ValidTime
- Inherits:
-
Object
- Object
- LetsCert::Runner::ValidTime
- Defined in:
- lib/letscert/runner/valid_time.rb
Overview
Class used to process validation time from String.
Instance Method Summary collapse
-
#initialize(str) ⇒ ValidTime
constructor
A new instance of ValidTime.
-
#to_s ⇒ String
Get time as string.
-
#to_seconds ⇒ Integer
Get time in seconds.
Constructor Details
#initialize(str) ⇒ ValidTime
Returns a new instance of ValidTime.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/letscert/runner/valid_time.rb', line 35 def initialize(str) m = str.match(/^(\d+)([mhd])?$/) if m @seconds = case m[2] when nil m[1].to_i when 'm' m[1].to_i * 60 when 'h' m[1].to_i * 60 * 60 when 'd' m[1].to_i * 24 * 60 * 60 end else raise OptionParser::InvalidArgument, "invalid argument: --valid-min #{str}" end @string = str end |
Instance Method Details
#to_s ⇒ String
Get time as string
63 64 65 |
# File 'lib/letscert/runner/valid_time.rb', line 63 def to_s @string end |
#to_seconds ⇒ Integer
Get time in seconds
57 58 59 |
# File 'lib/letscert/runner/valid_time.rb', line 57 def to_seconds @seconds end |