Sha256: 08e6e8e42bf35d85b5aa37025cc2608ecb72935a4a4db941fcc2b6fca82b297c

Contents?: true

Size: 1.38 KB

Versions: 2

Compression:

Stored size: 1.38 KB

Contents

require 'xc_metrics_aggregator/structure/structure'

module XcMetricsAggregator
    class Percentile
        attr_accessor :display_name, :is_represented, :identifier
        
        def initialize(json)
            @is_represented = json["isRepresented"]
            @display_name = json["displayName"]
            @identifier = json["identifier"]
        end
    end

    class PercentilesService
        def initialize(bundle_id, json)
            @json = json
            @bundle_id = bundle_id
        end
        
        def percentiles
            percentiles_json = @json["filterCriteriaSets"]["percentiles"]
            percentiles_json.map { |percentile_json| Percentile.new percentile_json }
        end
        
        def structure
            structure = XcMetricsAggregator::TableStructure.new
            structure.title = @bundle_id
            structure.headings = headings()
            structure.rows = rows()
            structure
        end
        
        def rows
            percentiles.map { |percentile| [percentile.display_name, percentile.identifier] }
        end

        def headings
            ["percentile", "id"]
        end

        def get_percentile(identifier)
            if identifier.nil?
                nil
            end


            res = percentiles.find do |percentile| 
                percentile.identifier == identifier
            end
        end
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
xc_metrics_aggregator-0.2.0 lib/xc_metrics_aggregator/service/percentiles_service.rb
xc_metrics_aggregator-0.1.0 lib/xc_metrics_aggregator/service/percentiles_service.rb