Class: Cucumber::Messages::Duration
- Defined in:
- lib/cucumber/messages/duration.rb
Overview
Represents the Duration message in Cucumber’s message protocol.
The structure is pretty close of the Timestamp one. For clarity, a second type
of message is used.
Instance Attribute Summary collapse
-
#nanos ⇒ Object
readonly
Non-negative fractions of a second at nanosecond resolution.
-
#seconds ⇒ Object
readonly
Returns the value of attribute seconds.
Class Method Summary collapse
-
.from_h(hash) ⇒ Object
Returns a new Duration from the given hash.
Instance Method Summary collapse
-
#initialize(seconds: 0, nanos: 0) ⇒ Duration
constructor
A new instance of Duration.
Methods inherited from Message
camelize, from_json, #to_h, #to_json
Constructor Details
#initialize(seconds: 0, nanos: 0) ⇒ Duration
Returns a new instance of Duration.
24 25 26 27 28 29 30 31 |
# File 'lib/cucumber/messages/duration.rb', line 24 def initialize( seconds: 0, nanos: 0 ) @seconds = seconds @nanos = nanos super() end |
Instance Attribute Details
#nanos ⇒ Object (readonly)
Non-negative fractions of a second at nanosecond resolution. Negative
second values with fractions must still have non-negative nanos values
that count forward in time. Must be from 0 to 999,999,999
inclusive.
22 23 24 |
# File 'lib/cucumber/messages/duration.rb', line 22 def nanos @nanos end |
#seconds ⇒ Object (readonly)
Returns the value of attribute seconds.
14 15 16 |
# File 'lib/cucumber/messages/duration.rb', line 14 def seconds @seconds end |
Class Method Details
.from_h(hash) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/cucumber/messages/duration.rb', line 40 def self.from_h(hash) return nil if hash.nil? new( seconds: hash[:seconds], nanos: hash[:nanos] ) end |