Class: FirebaseStats::DeviceUtils

Inherits:
Object
  • Object
show all
Defined in:
lib/device_utils.rb

Overview

Parses the Firebase CSV file into sections

Class Method Summary collapse

Class Method Details

.filter_device(device_data, platform) ⇒ Object

Filters a device list to only the requested platform

Parameters:

  • device_data (CSV::Table)
  • platform (Symbol)

    One of :all, :ios, :android



13
14
15
16
17
18
19
20
21
22
# File 'lib/device_utils.rb', line 13

def self.filter_device(device_data, platform)
  case platform
  when :android
    device_data.reject { |row| ios_device? row['Device model'] }
  when :ios
    device_data.select { |row| ios_device? row['Device model'] }
  else
    device_data
  end
end

.ios_device?(device_name) ⇒ Boolean

Is this device name an iOS device?

Parameters:

  • device_name (CSV::Row)

Returns:

  • (Boolean)


6
7
8
# File 'lib/device_utils.rb', line 6

def self.ios_device?(device_name)
  device_name.downcase.include?('iphone') or device_name.downcase.include?('ipad') or device_name.downcase.include?('ipod')
end