Sha256: 00694338cc8a84d752be98ca025e6035aa94adc0910903df947685096c899942
Contents?: true
Size: 1.38 KB
Versions: 1
Compression:
Stored size: 1.38 KB
Contents
require 'json' require 'time' require 'chronic' module Genability class Client # @private module Helpers private def pagination_params(options) { 'pageStart' => options['pageStart'] || options[:page_start] || options[:page], 'pageCount' => options['pageCount'] || options[:page_count] || options[:per_page], }.delete_if{ |k,v| v.nil? } end def convert_to_boolean(value = nil) return nil if value.nil? || value.empty? "true" end def multi_option_handler(value = nil) return nil if value.nil? if value.is_a?(Array) value.collect{|x| x.upcase}.join(',') else value.upcase end end def format_to_iso8601(date_time = nil) if date_time.respond_to?(:iso8601) genability_iso8601_converter(date_time) else parse_and_format_to_iso8601(date_time) end end def parse_and_format_to_iso8601(date_time = nil) parsed_date = Chronic.parse(date_time.to_s) parsed_date = parsed_date.nil? ? Time.parse(date_time.to_s) : parsed_date genability_iso8601_converter(parsed_date) rescue nil end def genability_iso8601_converter(date_time = nil) date_time.iso8601(1).gsub(/(?<=\-\d{2}):(?=\d{2})/, '') rescue nil end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
genability-0.2.0 | lib/genability/client/helpers.rb |