Module: Cryptum::Massage

Defined in:
lib/cryptum/massage.rb

Overview

Load in a Data Structure and Convert Strings to Integers or Floats if Possible.

Class Method Summary collapse

Class Method Details

.data(opts = {}) ⇒ Object

Supported Method Parameters

massaged_data = Cryptum::Massage.data(

struct: 'required - data structure to massage'

)



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/cryptum/massage.rb', line 22

public_class_method def self.data(opts = {})
  struct = opts[:struct]

  case struct
  when String
    begin
      numeric(struct: struct)
    rescue StandardError
      struct
    end
  when Array
    struct.map { |i| data(struct: i) }
  when Hash
    struct.merge(struct) { |_k, v| data(struct: v) }
  else
    struct
  end
rescue Interrupt, StandardError => e
  Cryptum::Log.append(level: :error, msg: e, which_self: self)
end

.helpObject

Display Usage for this Module



45
46
47
48
49
50
51
# File 'lib/cryptum/massage.rb', line 45

public_class_method def self.help
  puts "USAGE:
    massaged_data = Cryptum::Massage.data(
      struct: 'required - data structure to massage'
    )
  "
end