Class: Courgette::Device
- Inherits:
-
Object
- Object
- Courgette::Device
- Defined in:
- lib/courgette/device.rb
Instance Attribute Summary collapse
-
#ip ⇒ Object
readonly
Returns the value of attribute ip.
-
#vendor ⇒ Object
readonly
Returns the value of attribute vendor.
Instance Method Summary collapse
- #fetch(debug = false) ⇒ Object
-
#initialize(details) ⇒ Device
constructor
A new instance of Device.
- #to_s ⇒ Object
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
#ip ⇒ Object (readonly)
Returns the value of attribute ip.
3 4 5 |
# File 'lib/courgette/device.rb', line 3 def ip @ip end |
#vendor ⇒ Object (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_s ⇒ Object
16 17 18 |
# File 'lib/courgette/device.rb', line 16 def to_s "#{ip}/#{vendor}" end |