Module: Isaca::Helpers

Defined in:
lib/isaca/helpers.rb

Overview

A series of helper methods for parsing the way ISACA sends some data.

Class Method Summary collapse

Class Method Details

.normalize_member_type(type) ⇒ Symbol

ISACA has an abbreviated member type and this method will break down those abbreviations into one of the three primary types: member, non_member or student.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/isaca/helpers.rb', line 32

def self.normalize_member_type(type)
  return :non_member if type.nil?

  case type.upcase
    when 'COMP' then :member
    when 'LIFE' then :member
    when 'STUM' then :student
    when 'PENS' then :student
    when 'RG1' then :member
    when 'RG2' then :member
    when 'RETM' then :member
    when 'UADV' then :member
    when 'MEM' then :member
    when 'PEND' then :member
    when 'PENRG' then :member
    when 'EMPL' then :member
    else :non_member
  end
end

.parse_boolean(string) ⇒ Object

ISACA passes booleans as a string representation, this method helps parse these representations.



23
24
25
# File 'lib/isaca/helpers.rb', line 23

def self.parse_boolean(string)
  true.to_s.downcase == string.to_s.downcase
end

.strptime(string_time, format = '%m/%d/%Y %I:%M:%S %p') ⇒ DateTime

ISACA seems to use the default format to pass datetimes. This method exists so you don’t have to remember the parse format.



14
15
16
# File 'lib/isaca/helpers.rb', line 14

def self.strptime(string_time, format='%m/%d/%Y %I:%M:%S %p')
  (string_time.nil? || string_time.empty?) ? nil : DateTime.strptime(string_time, format)
end