Sha256: 5114e3d11113bd4a9e8d51b01d002ef9d9395e2ecaca5282b69a01cffb09bf27

Contents?: true

Size: 448 Bytes

Versions: 2

Compression:

Stored size: 448 Bytes

Contents

class TimeInfo

  SECOND = 1
  MINUTE = 60 * SECOND
  HOUR   = 60 * MINUTE
  DAY    = 24 * HOUR

  def time
    return Time.now - @unit_of_measure * @value
  end

  def initialize(value, unit_of_measure)
    descriptor = unit_of_measure[unit_of_measure.length - 1].chr == "s" ? unit_of_measure[0..unit_of_measure.length - 2] : unit_of_measure
    @value           = value
    @unit_of_measure = self.class.const_get(descriptor.upcase)
  end


end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruby-hackernews-1.1.0 lib/ruby-hackernews/domain/entry/time_info.rb
ruby-hackernews-1.0.1 lib/ruby-hackernews/domain/entry/time_info.rb