Class: Japin::Normalizer
- Inherits:
-
Object
- Object
- Japin::Normalizer
- Defined in:
- lib/japin/normalizer.rb
Instance Attribute Summary collapse
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#keys_case ⇒ Object
readonly
Returns the value of attribute keys_case.
-
#types_case ⇒ Object
readonly
Returns the value of attribute types_case.
Instance Method Summary collapse
-
#initialize(input, keys_case: nil, types_case: nil) ⇒ Normalizer
constructor
A new instance of Normalizer.
- #normalize ⇒ Object (also: #to_h)
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
#input ⇒ Object (readonly)
Returns the value of attribute input.
3 4 5 |
# File 'lib/japin/normalizer.rb', line 3 def input @input end |
#keys_case ⇒ Object (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_case ⇒ Object (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
#normalize ⇒ Object 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 |