class XcMetricsAggregator::DevicesService
Public Class Methods
new(bundle_id, json)
click to toggle source
# File lib/xc_metrics_aggregator/service/devices_service.rb, line 27 def initialize(bundle_id, json) @json = json @bundle_id = bundle_id end
Public Instance Methods
devicefamilies()
click to toggle source
# File lib/xc_metrics_aggregator/service/devices_service.rb, line 32 def devicefamilies device_families_json = @json["filterCriteriaSets"]["deviceFamilies"] device_families_json.map do |device_family_json| DeviceFamily.new device_family_json end end
get_device(identifier)
click to toggle source
# File lib/xc_metrics_aggregator/service/devices_service.rb, line 47 def get_device(identifier) if identifier.nil? nil end device = devicefamilies.map do |devicefamily| if devicefamily.identifier == identifier return devicefamily end devicefamily.devices.select do |device| device.identifier == identifier end end.flatten.first device end
structure()
click to toggle source
# File lib/xc_metrics_aggregator/service/devices_service.rb, line 39 def structure structure = XcMetricsAggregator::TableStructure.new structure.title = @bundle_id structure.headings = headings() structure.rows = rows() structure end
Private Instance Methods
headings()
click to toggle source
# File lib/xc_metrics_aggregator/service/devices_service.rb, line 81 def headings ["kind", "device", "id"] end
rows()
click to toggle source
# File lib/xc_metrics_aggregator/service/devices_service.rb, line 66 def rows rows = [] devicefamilies.each_with_index do |devicefamily, idx| device_display_names = devicefamily.devices.map{ |d| d.display_name }.join("\n") device_identifiers = devicefamily.devices.map{ |d| d.identifier }.join("\n") row = [devicefamily.display_name, device_display_names, device_identifiers] rows += if idx == devicefamilies.count - 1 [row] else [row] + [:separator] end end return rows end