Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/tempus.rb

Instance Method Summary collapse

Instance Method Details

#to_tempusObject

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