Class: Y2Network::Startmode
- Inherits:
-
Object
- Object
- Y2Network::Startmode
- Includes:
- 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
Instance Attribute Summary collapse
-
#name ⇒ Object
(also: #to_s)
readonly
Returns the value of attribute name.
Class Method Summary collapse
- .all ⇒ Object
-
.create(name) ⇒ Object
gets new instance of startmode for given type and its params.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
-
#initialize(name) ⇒ Startmode
constructor
A new instance of Startmode.
Constructor Details
#initialize(name) ⇒ Startmode
Returns a new instance of Startmode.
32 33 34 |
# File 'src/lib/y2network/startmode.rb', line 32 def initialize(name) @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly) Also known as: to_s
Returns the value of attribute name
29 30 31 |
# File 'src/lib/y2network/startmode.rb', line 29 def name @name end |
Class Method Details
.all ⇒ Object
47 48 49 50 |
# File 'src/lib/y2network/startmode.rb', line 47 def self.all require "y2network/startmodes" Startmodes.constants.map { |c| Startmodes.const_get(c).new } end |
.create(name) ⇒ Object
gets new instance of startmode for given type and its params
37 38 39 40 41 42 43 44 45 |
# File 'src/lib/y2network/startmode.rb', line 37 def self.create(name) name = "auto" if name == "onboot" # onboot is alias for auto # avoid circular dependencies require "y2network/startmodes" Startmodes.const_get(name.capitalize).new rescue NameError => e log.error "Invalid startmode #{e.inspect}" nil end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
52 53 54 |
# File 'src/lib/y2network/startmode.rb', line 52 def ==(other) name == other.name end |