<commit_before>#
# component.rb
# Cloudflare
#
# Copyright (c) 2016 <NAME>. All rights reserved.

require 'ostruct'

module Cloudflare
  module Util
    class Component
      # Get the nested value as a hash
      # @param [Object] an object to change into a hash
      # @return [Hash] hash of the val
      def self.parse(input)
        if input.is_a? Array
          array_of_ostructs = []
          input.each do |i|
            array_of_ostructs << Component.parse(i)
          end
          return array_of_ostructs
        else
          return Component.to_ostruct(input)
        end
      end

      def self.to_ostruct(input)
        o = OpenStruct.new(input)
        input.each do |k,v|
          o.send(:"#{k}=", Component.parse(v)) if v.is_a? Hash
        end
        o
      end

      def self.parse_response(response)
        parsed = JSON.parse(response.body)
        self.parse(parsed)
      end
    end
  end
end<commit_msg>fixing component<commit_after>#
# component.rb
# Cloudflare
#
# Copyright (c) 2016 <NAME>. All rights reserved.

require 'ostruct'

module Cloudflare
  module Util
    class Component
      # Get the nested value as a hash
      # @param [Object] an object to change into a hash
      # @return [Hash] hash of the val
      def self.parse(input)
        if input.is_a? Array
          array_of_ostructs = []
          input.each do |i|
            array_of_ostructs << Component.parse(i)
          end
          return array_of_ostructs
        else
          return Component.to_ostruct(input)
        end
      end

      def self.to_ostruct(input)
        o = OpenStruct.new(input)
        input.each do |k,v|
          o.send(:"#{k}=", Component.parse(v)) if v.is_a?(Hash) || v.is_a?(Array)
        end
        o
      end

      def self.parse_response(response)
        parsed = JSON.parse(response.body)
        self.parse(parsed)
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.09119496855345911, 'fraction_numerical': 0.0041928721174004195, 'mean_word_length': 1.9100609756097562, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5809498', 'n_tokens_mistral': 609, 'n_tokens_neox': 602, 'n_words': 166}