Sha256: d255618d6e692dbbcca0370bc35c57bd6c96d1869773b6e2759997d3f49fdd5d

Contents?: true

Size: 488 Bytes

Versions: 5

Compression:

Stored size: 488 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)    
    @value           = value
    if(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
      @unit_of_measure = self.class.const_get(descriptor.upcase)
    end
  end


end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ruby-hackernews-1.2.1 lib/ruby-hackernews/domain/entry/time_info.rb
ruby-hackernews-1.2.0 lib/ruby-hackernews/domain/entry/time_info.rb
ruby-hackernews-1.1.3 lib/ruby-hackernews/domain/entry/time_info.rb
ruby-hackernews-1.1.2 lib/ruby-hackernews/domain/entry/time_info.rb
ruby-hackernews-1.1.1 lib/ruby-hackernews/domain/entry/time_info.rb