Module: Cucumber::Messages::TimeConversion
- Included in:
- Core::Test::Result::Duration, Core::Test::Result::UnknownDuration, Formatter::MessageBuilder
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-messages-18.0.0/lib/cucumber/messages/time_conversion.rb
Constant Summary collapse
- NANOSECONDS_PER_SECOND =
1000000000
Instance Method Summary collapse
- #duration_to_seconds(duration) ⇒ Object
- #seconds_to_duration(seconds_float) ⇒ Object
- #time_to_timestamp(time) ⇒ Object
- #timestamp_to_time(timestamp) ⇒ Object
Instance Method Details
#duration_to_seconds(duration) ⇒ Object
26 27 28 29 30 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-messages-18.0.0/lib/cucumber/messages/time_conversion.rb', line 26 def duration_to_seconds(duration) seconds_part = duration['seconds'] nanos_part = duration['nanos'].to_f / NANOSECONDS_PER_SECOND seconds_part + nanos_part end |
#seconds_to_duration(seconds_float) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-messages-18.0.0/lib/cucumber/messages/time_conversion.rb', line 17 def seconds_to_duration(seconds_float) seconds, second_modulus = seconds_float.divmod(1) nanos = second_modulus * NANOSECONDS_PER_SECOND { 'seconds' => seconds, 'nanos' => nanos.to_i } end |
#time_to_timestamp(time) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-messages-18.0.0/lib/cucumber/messages/time_conversion.rb', line 6 def (time) { 'seconds' => time.to_i, 'nanos' => time.nsec } end |
#timestamp_to_time(timestamp) ⇒ Object
13 14 15 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-messages-18.0.0/lib/cucumber/messages/time_conversion.rb', line 13 def () Time.at(['seconds'] + ['nanos'].to_f / NANOSECONDS_PER_SECOND) end |