Class: Courgette::Device

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(details) ⇒ Device

Returns a new instance of Device.



5
6
7
8
9
# File 'lib/courgette/device.rb', line 5

def initialize(details)
  @ip = details['ip']
  @vendor = details['vendor']
  @details = details
end

Instance Attribute Details

#ipObject (readonly)

Returns the value of attribute ip.



3
4
5
# File 'lib/courgette/device.rb', line 3

def ip
  @ip
end

#vendorObject (readonly)

Returns the value of attribute vendor.



3
4
5
# File 'lib/courgette/device.rb', line 3

def vendor
  @vendor
end

Instance Method Details

#fetch(debug = false) ⇒ Object



11
12
13
14
# File 'lib/courgette/device.rb', line 11

def fetch(debug = false)
  chain = Chain.all.find { |chain| chain.responsible_of(@vendor) }
  chain ? chain.apply(@ip, @details) : raise("Vendor not found")
end

#to_sObject



16
17
18
# File 'lib/courgette/device.rb', line 16

def to_s
  "#{ip}/#{vendor}"
end