Class: SimCtl::Device

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Object

#initialize

Constructor Details

This class inherits a constructor from SimCtl::Object

Instance Attribute Details

#availabilityObject (readonly)

Returns the value of attribute availability



9
10
11
# File 'lib/simctl/device.rb', line 9

def availability
  @availability
end

#nameObject (readonly)

Returns the value of attribute name



9
10
11
# File 'lib/simctl/device.rb', line 9

def name
  @name
end

#osObject (readonly)

Returns the value of attribute os



9
10
11
# File 'lib/simctl/device.rb', line 9

def os
  @os
end

#statesym (readonly)

Returns the state of the device

Returns:

  • (sym)


109
110
111
# File 'lib/simctl/device.rb', line 109

def state
  @state
end

#udidObject (readonly)

Returns the value of attribute udid



9
10
11
# File 'lib/simctl/device.rb', line 9

def udid
  @udid
end

Instance Method Details

#==(other) ⇒ Object



124
125
126
127
128
# File 'lib/simctl/device.rb', line 124

def ==(other)
  return false if other.nil?
  return false unless other.kind_of? Device
  other.udid == udid
end

#boot!void

This method returns an undefined value.

Boots the device



14
15
16
# File 'lib/simctl/device.rb', line 14

def boot!
  SimCtl.boot_device(self)
end

#delete!void

This method returns an undefined value.

Deletes the device



21
22
23
# File 'lib/simctl/device.rb', line 21

def delete!
  SimCtl.delete_device(self)
end

#devicetypeSimCtl::DeviceType

Returns the device type

Returns:



28
29
30
# File 'lib/simctl/device.rb', line 28

def devicetype
  @devicetype ||= SimCtl.devicetype(identifier: plist.deviceType)
end

#disable_keyboard_helpers!void

This method returns an undefined value.

Disables the keyboard helpers



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/simctl/device.rb', line 35

def disable_keyboard_helpers!
  path.edit path.preferences_plist do |plist|
    %w(
      KeyboardPeriodShortcut
      KeyboardAutocapitalization
      KeyboardCheckSpelling
      KeyboardAssistant
      KeyboardAutocorrection
      KeyboardPrediction
      KeyboardShowPredictionBar
      KeyboardCapsLock
    ).each do |key|
      plist[key] = false
    end
    plist
  end
end

#erase!void

This method returns an undefined value.

Erases the device



56
57
58
# File 'lib/simctl/device.rb', line 56

def erase!
  SimCtl.erase_device(self)
end

#kill!void

This method returns an undefined value.

Kills the device



63
64
65
# File 'lib/simctl/device.rb', line 63

def kill!
  SimCtl.kill_device(self)
end

#launch!(scale = 1.0, opts = {}) ⇒ void

This method returns an undefined value.

Launches the Simulator



70
71
72
# File 'lib/simctl/device.rb', line 70

def launch!(scale=1.0, opts={})
  SimCtl.launch_device(self, scale, opts)
end

#pathObject



74
75
76
# File 'lib/simctl/device.rb', line 74

def path
  @path ||= DevicePath.new(udid)
end

#rename!(name) ⇒ void

This method returns an undefined value.

Renames the device



81
82
83
# File 'lib/simctl/device.rb', line 81

def rename!(name)
  SimCtl.rename_device(self, name)
end

#reset!void

This method returns an undefined value.

Resets the device



88
89
90
# File 'lib/simctl/device.rb', line 88

def reset!
  SimCtl.reset_device name, devicetype, runtime
end

#runtimeSimCtl::Runtime

Resets the runtime

Returns:



95
96
97
# File 'lib/simctl/device.rb', line 95

def runtime
  @runtime ||= SimCtl.runtime(identifier: plist.runtime)
end

#shutdown!void

This method returns an undefined value.

Shuts down the runtime



102
103
104
# File 'lib/simctl/device.rb', line 102

def shutdown!
  SimCtl.shutdown_device(self)
end

#wait!(timeout = 15) ⇒ void

This method returns an undefined value.

Reloads the device until the given block returns true



116
117
118
119
120
121
122
# File 'lib/simctl/device.rb', line 116

def wait!(timeout=15)
  Timeout::timeout(timeout) do
    loop do
      break if yield SimCtl.device(udid: udid)
    end
  end
end