Sha256: e91811434f3514698d98817eff8d65fb681d54fc42b68aedcb2fc33aca694b31

Contents?: true

Size: 736 Bytes

Versions: 24

Compression:

Stored size: 736 Bytes

Contents

module Sportradar
  module Api
    class Data

      # Attributes that have a value
      def attributes
        all_attributes.select {|x| !self.send(x).nil? }
      end

      def all_attributes
        self.instance_variables.map{|attribute| attribute.to_s.gsub('@', '').to_sym }
      end

      def parse_into_array(selector: , klass: )
        if selector.is_a?(Array)
          selector.map {|x| klass.new x }
        elsif selector.is_a?(Hash)
          [ klass.new(selector) ]
        end
      end

      def parse_out_hashes(data_element)
        if data_element && data_element.is_a?(Array)
          data_element.find {|elem| elem.is_a?(Hash) }
        else
          data_element
        end
      end

    end

  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
sportradar-api-0.9.3 lib/sportradar/api/data.rb
sportradar-api-0.9.2 lib/sportradar/api/data.rb
sportradar-api-0.9.1 lib/sportradar/api/data.rb
sportradar-api-0.9.0 lib/sportradar/api/data.rb