Represents a duration of time, corresponding to the Duration datatype in DSE Graph. In DSE Graph, this type is represented by the Java 8 Duration type.

Specifications:
Duration should produce a valid string representation
expect(Duration.new(1, 2, 3, 4).to_s).to eq('P1DT2H3M4.0S')
expect(Duration.new(nil, nil, nil, nil).to_s).to eq('P0DT0H0M0.0S')
Duration should consider equivalent Durations as equal
expect(Duration.new(1, 2, 3, 4)).to eq(Duration.new(0, 26, 0, 184))

Inherits

Object

Methods

self.

new

(days, hours, minutes, seconds)

Create a Dse::Graph::Duration object. All arguments are internally coerced to desired types.

Parameters:
Name Type Details
days Integer number of days in the time-frame. May be negative.
hours Integer number of hours in the time-frame. May be negative.
minutes Integer number of minutes in the time-frame. May be negative.
seconds Float number of seconds in the time-frame. May be negative.
self.

parse

(duration)

Parse a duration string from DSE Graph and construct a Dse::Graph::Duration object

Parameters:
Name Type Details
duration String duration string from DSE Graph.
Raises:
Type Details
ArgumentError if the duration string fails to parse.

days

read or write

Days in duration of time. May be negative. Is internally coerced to an integer, so a value being assigned need not be an Integer itself.

Returns:
Type Details
Integer days in duration of time.

hours

read or write

Hours in duration of time. May be negative. Is internally coerced to an integer, so a value being assigned need not be an Integer itself.

Returns:
Type Details
Integer hours in duration of time.

minutes

read or write

Minutes in duration of time. May be negative. Is internally coerced to an integer, so a value being assigned need not be an Integer itself.

Returns:
Type Details
Integer minutes in duration of time.

seconds

read or write

Seconds in duration of time. May be negative. Is internally coerced to an float, so a value being assigned need not be an Float itself.

Returns:
Type Details
Float seconds in duration of time.

to_s

A string formatted as PnDTnHnMn.nS, where n is a number that goes with the character code following it.

D - days
H - hours
M - minutes
S - seconds

Examples:
a duration of 1 day, 2 hours, 3 minutes, 4.5 seconds
P1DT2H3M4.5S
Returns:
Type Details
String this Dse::Graph::Duration as a string formatted PnDTnHnMn.nS.
See Also:

as_seconds

Returns this Dse::Graph::Duration object converted to seconds

Returns:
Type Details
Float this Dse::Graph::Duration object converted to seconds