Class: Device

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(idx, id, name) ⇒ Device

Returns a new instance of Device.



4
5
6
7
8
# File 'lib/replicant/device.rb', line 4

def initialize(idx, id, name)
  @idx = idx
  @id = id
  @name = name
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



2
3
4
# File 'lib/replicant/device.rb', line 2

def id
  @id
end

#idxObject (readonly)

Returns the value of attribute idx.



2
3
4
# File 'lib/replicant/device.rb', line 2

def idx
  @idx
end

#nameObject (readonly)

Returns the value of attribute name.



2
3
4
# File 'lib/replicant/device.rb', line 2

def name
  @name
end

Instance Method Details

#emulator?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/replicant/device.rb', line 10

def emulator?
  @id.start_with?('emulator-')
end

#physical_device?Boolean

Returns:

  • (Boolean)


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

def physical_device?
  !emulator?
end

#short_nameObject



18
19
20
# File 'lib/replicant/device.rb', line 18

def short_name
  "#{@name[0..4]}[#{@idx}]"
end

#to_sObject



22
23
24
# File 'lib/replicant/device.rb', line 22

def to_s
  "#{@id} [#{@name}]"
end