Class: XCSim::OSDevices

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/xcsim/rbOSDevices.rb

Overview

A collection of DeviceID objects related to a given iOS Simulator OS version

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, devices) ⇒ OSDevices

Initializes an OSDevices instance with a given OSID and a collection of devices

id

OSID to associate with the OSDevices object

devices

A collection of DeviceID objects. Should support #each method for enumeration.



17
18
19
20
21
22
23
24
# File 'lib/xcsim/rbOSDevices.rb', line 17

def initialize(id, devices)
  @id = id

  devicesHash = {}
  devices.each{ |d| devicesHash[d.name] = d }

  @devices = devicesHash
end

Instance Attribute Details

#devicesObject (readonly)

A hash of deviceName => DeviceID



12
13
14
# File 'lib/xcsim/rbOSDevices.rb', line 12

def devices
  @devices
end

#idObject (readonly)

An OSID of the iOS Simulator OS version related to the OSDevices collection



9
10
11
# File 'lib/xcsim/rbOSDevices.rb', line 9

def id
  @id
end

Instance Method Details

#<=>(other) ⇒ Object

Compares by id



39
40
41
# File 'lib/xcsim/rbOSDevices.rb', line 39

def <=>(other)
  @id <=> other.id
end

#inspectObject

Returns a string in 'iOS 9.0 (5 devices)' format



27
28
29
# File 'lib/xcsim/rbOSDevices.rb', line 27

def inspect
  "#{@id.inspect} (#{@devices.count} devices)"
end

#to_sObject

Same as #inspect



32
33
34
# File 'lib/xcsim/rbOSDevices.rb', line 32

def to_s
  inspect
end