Class: Cucumber::Core::Test::Result::Duration

Inherits:
Object
  • Object
show all
Includes:
Messages::TimeConversion
Defined in:
lib/cucumber/core/test/result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(nanoseconds) ⇒ Duration

Returns a new instance of Duration.



411
412
413
# File 'lib/cucumber/core/test/result.rb', line 411

def initialize(nanoseconds)
  @nanoseconds = nanoseconds
end

Instance Attribute Details

#nanosecondsObject (readonly)

Returns the value of attribute nanoseconds.



409
410
411
# File 'lib/cucumber/core/test/result.rb', line 409

def nanoseconds
  @nanoseconds
end

Instance Method Details

#to_message_durationObject



415
416
417
418
419
420
421
422
423
424
# File 'lib/cucumber/core/test/result.rb', line 415

def to_message_duration
  duration_hash = seconds_to_duration(nanoseconds.to_f / NANOSECONDS_PER_SECOND)
  duration_hash.transform_keys! do |key|
    key.to_sym
  rescue Error
    return key
  end

  Cucumber::Messages::Duration.from_h(duration_hash)
end