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.24 lib/sportradar/api/data.rb
sportradar-api-0.9.23 lib/sportradar/api/data.rb
sportradar-api-0.9.22 lib/sportradar/api/data.rb
sportradar-api-0.9.21 lib/sportradar/api/data.rb
sportradar-api-0.9.20 lib/sportradar/api/data.rb
sportradar-api-0.9.19 lib/sportradar/api/data.rb
sportradar-api-0.9.18 lib/sportradar/api/data.rb
sportradar-api-0.9.17 lib/sportradar/api/data.rb
sportradar-api-0.9.16 lib/sportradar/api/data.rb
sportradar-api-0.9.15 lib/sportradar/api/data.rb
sportradar-api-0.9.14 lib/sportradar/api/data.rb
sportradar-api-0.9.13 lib/sportradar/api/data.rb
sportradar-api-0.9.12 lib/sportradar/api/data.rb
sportradar-api-0.9.11 lib/sportradar/api/data.rb
sportradar-api-0.9.10 lib/sportradar/api/data.rb
sportradar-api-0.9.9 lib/sportradar/api/data.rb
sportradar-api-0.9.8 lib/sportradar/api/data.rb
sportradar-api-0.9.7 lib/sportradar/api/data.rb
sportradar-api-0.9.6 lib/sportradar/api/data.rb
sportradar-api-0.9.5 lib/sportradar/api/data.rb