module ROBundle::Util

A module with lots of utility functions.

Public Class Methods

clean_json(json_hash) → Hash click to toggle source

Remove empty strings and nils from a json hash structure.

# File lib/ro-bundle/util.rb, line 19
def self.clean_json(structure)
  structure.delete_if do |_, v|
    v.nil? || (v.respond_to?(:empty?) && v.empty?)
is_absolute_uri?(uri) → true or false click to toggle source

Is the supplied URI absolute? An absolute URI is a valid URI that starts with a scheme, such as http, https or urn.

# File lib/ro-bundle/util.rb, line 39
def self.is_absolute_uri?(uri)
  uri = URI.parse(uri) unless uri.is_a?(URI)
rescue URI::InvalidURIError
parse_time(time) → Time click to toggle source

Parse a time string into a Time object. Does not try to parse nil.

# File lib/ro-bundle/util.rb, line 29
def self.parse_time(time)
  return if time.nil?
strip_leading_slash(string) click to toggle source

Return the supplied string with a leading slash removed.

# File lib/ro-bundle/util.rb, line 50
def self.strip_leading_slash(string)
  return if string.nil?
  string.sub(/^\//, "")