Module: Urbanairship::Util

Defined in:
lib/urbanairship/util.rb

Class Method Summary collapse

Class Method Details

.time_format(datetime) ⇒ String

Returns the datetime formatted as expected by the API.

Returns:

  • (String)

    the datetime formatted as expected by the API



11
12
13
# File 'lib/urbanairship/util.rb', line 11

def time_format(datetime)
  datetime.strftime('%Y-%m-%dT%H:%M:%S')
end

.validate(obj, name, regex) ⇒ Object

Raises:

  • (ArgumentError)

    unless obj matches the pattern.



6
7
8
# File 'lib/urbanairship/util.rb', line 6

def validate(obj, name, regex)
  fail ArgumentError, "#{obj} isn't a valid #{name}" unless obj =~ regex
end