Method: Config#get_duration

Defined in:
lib/hocon/config.rb

#get_duration(path, unit) ⇒ Object

Gets a value as a duration in a specified java.util.concurrent.TimeUnit TimeUnit. If the value is already a number, then it’s taken as milliseconds and then converted to the requested TimeUnit; if it’s a string, it’s parsed understanding units suffixes like “10m” or “5ns” as documented in the <a href=“github.com/typesafehub/config/blob/master/HOCON.md”>the spec</a>.

Parameters:

  • path

    path expression

  • unit

    convert the return value to this time unit

Returns:

  • the duration value at the requested path, in the given TimeUnit

Raises:

Since:

  • 1.2.0



692
693
694
# File 'lib/hocon/config.rb', line 692

def get_duration(path, unit)
  raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `get_duration` (#{self.class})"
end