Class: Y2Network::Startmode

Inherits:
Object
  • Object
show all
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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Startmode


32
33
34
# File 'src/lib/y2network/startmode.rb', line 32

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject (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

.allObject


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