Class: Y2Network::Startmode
- Inherits:
-
Object
- Object
- Y2Network::Startmode
- Includes:
- Yast2::Equatable, Yast::Logger
- Defined in:
- src/lib/y2network/startmode.rb
Overview
Base class for startmode. It allows to create new one according to name or anlist all.
Its child have to define to_human_string
method and possibly its own specialized attributes.
TODO: as backends differs, we probably also need to have flag there to which backends
mode exists
Direct Known Subclasses
Y2Network::Startmodes::Auto, Y2Network::Startmodes::Hotplug, Y2Network::Startmodes::Ifplugd, Y2Network::Startmodes::Manual, Y2Network::Startmodes::Nfsroot, Y2Network::Startmodes::Off
Constant Summary collapse
- ALIASES =
To be backward compliant 'boot', 'on' and 'onboot' are aliases for 'auto' (bsc#1186910)
{ "boot" => "auto", "onboot" => "auto", "on" => "auto" }.freeze
Instance Attribute Summary collapse
-
#alias_name ⇒ Object
readonly
Returns the value of attribute alias_name.
-
#name ⇒ Object
(also: #to_s)
readonly
Returns the value of attribute name.
Class Method Summary collapse
- .all ⇒ Object
-
.create(mode) ⇒ Object
gets new instance of startmode for given type and its params.
Instance Method Summary collapse
-
#initialize(name, alias_name: nil) ⇒ Startmode
constructor
A new instance of Startmode.
Constructor Details
#initialize(name, alias_name: nil) ⇒ Startmode
Returns a new instance of Startmode.
47 48 49 50 |
# File 'src/lib/y2network/startmode.rb', line 47 def initialize(name, alias_name: nil) @name = name @alias_name = alias_name end |
Instance Attribute Details
#alias_name ⇒ Object (readonly)
Returns the value of attribute alias_name.
41 42 43 |
# File 'src/lib/y2network/startmode.rb', line 41 def alias_name @alias_name end |
#name ⇒ Object (readonly) Also known as: to_s
Returns the value of attribute name.
40 41 42 |
# File 'src/lib/y2network/startmode.rb', line 40 def name @name end |
Class Method Details
.all ⇒ Object
66 67 68 69 |
# File 'src/lib/y2network/startmode.rb', line 66 def self.all require "y2network/startmodes" Startmodes.constants.map { |c| Startmodes.const_get(c).new } end |
.create(mode) ⇒ Object
gets new instance of startmode for given type and its params
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'src/lib/y2network/startmode.rb', line 53 def self.create(mode) name = ALIASES[mode] || mode alias_name = ALIASES[mode] ? mode : nil # avoid circular dependencies require "y2network/startmodes" const = Startmodes.const_get(name.capitalize) alias_name ? const.new(alias_name: alias_name) : const.new rescue NameError => e log.error "Invalid startmode #{e.inspect}" nil end |