Module: Finlight::ModelParsing

Defined in:
lib/finlight/models.rb

Overview

Shared parsing helpers for wire-format (camelCase) JSON hashes.

Class Method Summary collapse

Class Method Details

.to_float(value) ⇒ Object

The API sometimes delivers numbers as strings (e.g. "confidence":"0.9").



9
10
11
12
13
14
15
# File 'lib/finlight/models.rb', line 9

def to_float(value)
  return nil if value.nil?

  Float(value)
rescue ArgumentError, TypeError
  nil
end

.to_string_list(value) ⇒ Object



17
18
19
# File 'lib/finlight/models.rb', line 17

def to_string_list(value)
  value&.map(&:to_s)
end