lib/fitbit_api/helpers/utils.rb in fitbit_api-0.17.1 vs lib/fitbit_api/helpers/utils.rb in fitbit_api-1.0.0

- old
+ new

@@ -2,10 +2,12 @@ module FitbitAPI class Client PERIODS = %w[1d 7d 30d 1w 1m 3m 6m 1y max].freeze + private + def format_date(date) if [Date, Time, DateTime].include?(date.class) date.strftime('%Y-%m-%d') elsif date.is_a? String if date =~ /\d{4}-\d{2}-\d{2}/ @@ -14,11 +16,11 @@ raise FitbitAPI::InvalidArgumentError, "Invalid argument [\"#{date}\"] - string must follow yyyy-MM-dd format." end else raise FitbitAPI::InvalidArgumentError, - "Invalid type [#{date.class}] - provide a Date/Time/DateTime or a String(yyyy-MM-dd format)." + "Invalid type [#{date.class}] - provide a Date, Time, DateTime, or a String in yyyy-MM-dd format." end end def format_time(time) if [Time, DateTime].include?(time.class) @@ -27,13 +29,12 @@ unless time =~ /\d{2}:\d{2}/ raise FitbitAPI::InvalidArgumentError, "Invalid argument [\"#{time}\"] - string must follow HH:mm format." end time - else raise FitbitAPI::InvalidArgumentError, - "Invalid type [#{time.class}] - provide a Time/DateTime or a String(HH:mm format)." + "Invalid type [#{time.class}] - provide a Time, DateTime, or a String in HH:mm format." end end def format_scope(scope) scope.is_a?(Array) ? scope.join(' ') : scope