Class: Japin::Normalizer

Inherits:
Object
  • Object
show all
Defined in:
lib/japin/normalizer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input, keys_case: nil, types_case: nil) ⇒ Normalizer

Returns a new instance of Normalizer.



5
6
7
8
9
# File 'lib/japin/normalizer.rb', line 5

def initialize(input, keys_case: nil, types_case: nil)
    @input = deep_transform_keys(input, &:to_s)
    @keys_case = keys_case
    @types_case = types_case
end

Instance Attribute Details

#inputObject (readonly)

Returns the value of attribute input.



3
4
5
# File 'lib/japin/normalizer.rb', line 3

def input
  @input
end

#keys_caseObject (readonly)

Returns the value of attribute keys_case.



3
4
5
# File 'lib/japin/normalizer.rb', line 3

def keys_case
  @keys_case
end

#types_caseObject (readonly)

Returns the value of attribute types_case.



3
4
5
# File 'lib/japin/normalizer.rb', line 3

def types_case
  @types_case
end

Instance Method Details

#normalizeObject Also known as: to_h



11
12
13
14
15
16
17
# File 'lib/japin/normalizer.rb', line 11

def normalize
    return @output if @output

    @output = {}
    input.slice('data', 'included').each_value { |entities| extract_entities(entities) }
    @output
end