Module: L43::Time::Ts
- Included in:
- Parser
- Defined in:
- lib/l43/time/ts.rb
Defined Under Namespace
Modules: Helper
Constant Summary collapse
- DecimalPart =
%r{\A(.*)\.(\d+)\z}- Seperators =
Regexp.compile(%w[. : _ -].map { Regexp.escape(it) }.join('|'))
Instance Method Summary collapse
- #duration_as_string(str) ⇒ Object (also: #duration_s)
- #duration_as_string!(str) ⇒ Object (also: #duration_s!)
Instance Method Details
#duration_as_string(str) ⇒ Object Also known as: duration_s
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/l43/time/ts.rb', line 23 def duration_as_string(str) header = '' if str.start_with?('+') str = str[1..] elsif str.start_with?('-') str = str[1..] header = '-' end if DecimalPart === str Helper.duration_as_string($1, $2, header) else Helper.duration_as_string(str, "0", header) end end |
#duration_as_string!(str) ⇒ Object Also known as: duration_s!
13 14 15 16 17 18 19 20 |
# File 'lib/l43/time/ts.rb', line 13 def duration_as_string!(str) case duration_as_string(str) in :ok, value value in :error, msg raise BadFormat, msg end end |