Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/tempus.rb
Instance Method Summary collapse
-
#to_tempus ⇒ Object
Criando método para conversão da classe String.
Instance Method Details
#to_tempus ⇒ Object
Criando método para conversão da classe String
210 211 212 213 214 215 216 217 218 |
# File 'lib/tempus.rb', line 210 def to_tempus str = (self).to_s.split(":") value = 0 [:hours, :minutes, :seconds].each_with_index do |m, i| value += str.at(i).to_i.abs.send(m.to_s) end value = -value if str.to_s.include?('-') Tempus.new(value) end |