Class: Y2Network::Backend
- Inherits:
-
Object
- Object
- Y2Network::Backend
- Includes:
- Yast2::Equatable, Yast::I18n
- Defined in:
- src/lib/y2network/backend.rb
Overview
This class is the base class for the different network backends and also responsible of listing the supported ones.
Direct Known Subclasses
Y2Network::Backends::Netconfig, Y2Network::Backends::NetworkManager, Y2Network::Backends::None, Y2Network::Backends::Wicked
Instance Attribute Summary collapse
-
#id ⇒ Symbol
readonly
Backend id.
Class Method Summary collapse
-
.all ⇒ Array<Backend>
Return all the supported backends.
-
.available ⇒ Array<Backend>
Return all the supported and installed backends.
-
.by_id(id) ⇒ Backend?
Return the backend with the given id when supported.
Instance Method Summary collapse
-
#available? ⇒ Boolean
Return whether the backend is available or not.
-
#initialize(id) ⇒ Backend
constructor
Constructor.
-
#label ⇒ String
Return the translated backend label.
-
#name ⇒ String
(also: #to_s)
Return the backend short name.
-
#packages ⇒ Array<String>
Return a list of the required packages for this backend.
Constructor Details
Instance Attribute Details
#id ⇒ Symbol (readonly)
Returns backend id.
31 32 33 |
# File 'src/lib/y2network/backend.rb', line 31 def id @id end |
Class Method Details
.all ⇒ Array<Backend>
Return all the supported backends
64 65 66 67 |
# File 'src/lib/y2network/backend.rb', line 64 def self.all require "y2network/backends" @all ||= Backends.constants.map { |c| Backends.const_get(c).new } end |
.available ⇒ Array<Backend>
Return all the supported and installed backends
72 73 74 |
# File 'src/lib/y2network/backend.rb', line 72 def self.available all.select(&:available?) end |
.by_id(id) ⇒ Backend?
Return the backend with the given id when supported
80 81 82 |
# File 'src/lib/y2network/backend.rb', line 80 def self.by_id(id) all.find { |b| b.id == id } end |
Instance Method Details
#available? ⇒ Boolean
Return whether the backend is available or not
87 88 89 |
# File 'src/lib/y2network/backend.rb', line 87 def available? Yast::NetworkService.is_backend_available(id) end |
#label ⇒ String
Return the translated backend label
55 56 57 |
# File 'src/lib/y2network/backend.rb', line 55 def label raise NotImplementedError end |
#name ⇒ String Also known as: to_s
Return the backend short name
48 49 50 |
# File 'src/lib/y2network/backend.rb', line 48 def name id.to_s end |
#packages ⇒ Array<String>
Return a list of the required packages for this backend
94 95 96 |
# File 'src/lib/y2network/backend.rb', line 94 def packages [] end |