Sha256: 0579bac9081795c0fa780706db051f3f959b0792120012372723c14bf68ee2ef

Contents?: true

Size: 695 Bytes

Versions: 1

Compression:

Stored size: 695 Bytes

Contents

# Accepts default return value of 'date' system command e.g.
# Wed Apr 15 19:29:51 CEST 2015

# Also accepts any argument processable by Time#parse

class SecondsCalculator < String

  class << self

    def run(time_string)
      puts(new(time_string)) if time_string
    end

  end

  private

  def initialize(time_string)
    super(time_string)
    find_start_time
    find_time_taken
    make_presentable
  end

  def find_start_time
    @start_time = Time.parse(self)
  end

  def find_time_taken
    @time_taken = current_time - @start_time
  end

  def current_time
    Time.new
  end

  def make_presentable
    self.gsub!(/^.*$/, "Started server in #{@time_taken} seconds.")
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
puma-clocker-0.1.0 lib/puma/clocker/seconds_calculator.rb