Sha256: 2f6d219a2cf398d0d125852ed0fe30234fc8d05a2702486d09729b683aa14f12

Contents?: true

Size: 1.18 KB

Versions: 18

Compression:

Stored size: 1.18 KB

Contents

module SportsDataApi
  module Golf
    class Summary
      attr_reader :tour, :year, :id, :name, :purse, :winning_share, :currency,
        :points, :event_type, :start_date, :end_date, :course_timezone,
        :coverage, :status

      def initialize(tour, year, data)
        @tour = tour
        @year = year
        @data = data
        @id = data['id']
        @name = data['name']
        @purse = data['purse']
        @winning_share = data['winning_share']
        @currency = data['currency']
        @points = data['points']
        @event_type = data['event_type']
        @start_date = data['start_date']
        @end_date = data['end_date']
        @course_timezone = data['course_timezone']
        @coverage = data['coverage']
        @status = data['status']
      end

      def field
        @field ||= safe_map('field') do |json|
          SportsDataApi::Golf::Player.new(json)
        end
      end

      def rounds
        @rounds ||= safe_map('rounds') do |json|
          SportsDataApi::Golf::Round.new(json)
        end
      end

      private

      attr_reader :data

      def safe_map(field)
        data[field].map { |val| yield(val) } if data[field]
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
sports_data_api-0.15.3 lib/sports_data_api/golf/summary.rb
sports_data_api-0.15.2 lib/sports_data_api/golf/summary.rb
sports_data_api-0.15.1 lib/sports_data_api/golf/summary.rb
sports_data_api-0.15.0 lib/sports_data_api/golf/summary.rb
sports_data_api-0.14.1 lib/sports_data_api/golf/summary.rb
sports_data_api-0.14.0 lib/sports_data_api/golf/summary.rb
sports_data_api-0.13.0 lib/sports_data_api/golf/summary.rb
sports_data_api-0.12.1 lib/sports_data_api/golf/summary.rb
sports_data_api-0.12.0 lib/sports_data_api/golf/summary.rb
sports_data_api-0.11.6 lib/sports_data_api/golf/summary.rb
sports_data_api-0.11.5 lib/sports_data_api/golf/summary.rb
sports_data_api-0.11.3 lib/sports_data_api/golf/summary.rb
sports_data_api-0.11.2 lib/sports_data_api/golf/summary.rb
sports_data_api-0.11.1 lib/sports_data_api/golf/summary.rb
sports_data_api-0.11.0 lib/sports_data_api/golf/summary.rb
sports_data_api-0.10.1 lib/sports_data_api/golf/summary.rb
sports_data_api-0.10.0 lib/sports_data_api/golf/summary.rb
sports_data_api-0.9.2 lib/sports_data_api/golf/summary.rb