Class: Dashbeautiful::Device

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

Overview

description TODO

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(network, **attributes) ⇒ Device

Returns a new instance of Device.



23
24
25
26
27
28
29
30
# File 'lib/dashbeautiful/device.rb', line 23

def initialize(network, **attributes)
  @network = network
  @name = attributes[:name]
  @serial = attributes[:serial]
  @mac = attributes[:mac]
  @model = attributes[:model]
  @tags = attributes[:tags]
end

Instance Attribute Details

#macObject (readonly)

Returns the value of attribute mac.



4
5
6
# File 'lib/dashbeautiful/device.rb', line 4

def mac
  @mac
end

#modelObject (readonly)

Returns the value of attribute model.



4
5
6
# File 'lib/dashbeautiful/device.rb', line 4

def model
  @model
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/dashbeautiful/device.rb', line 4

def name
  @name
end

#networkObject (readonly)

Returns the value of attribute network.



4
5
6
# File 'lib/dashbeautiful/device.rb', line 4

def network
  @network
end

#serialObject (readonly)

Returns the value of attribute serial.



4
5
6
# File 'lib/dashbeautiful/device.rb', line 4

def serial
  @serial
end

#tagsObject (readonly)

Returns the value of attribute tags.



4
5
6
# File 'lib/dashbeautiful/device.rb', line 4

def tags
  @tags
end

Class Method Details

.all(network) ⇒ Object

Raises:

  • (ArgumentError)


17
18
19
20
21
# File 'lib/dashbeautiful/device.rb', line 17

def self.all(network)
  raise ArgumentError, 'must pass a Network' if network.nil?

  network.devices
end

.create(*args, **kwargs) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/dashbeautiful/device.rb', line 6

def self.create(*args, **kwargs)
  type = case kwargs[:model]
         when /MV/ then CameraDevice
         when /MS/ then SwitchDevice
         when /MR/ then WirelessDevice
         when /MX/ then ApplianceDevice
         else Device
         end
  type.new(*args, **kwargs)
end