Class: Bootloader::BlsSections

Inherits:
Object
  • Object
show all
Includes:
Yast::I18n, Yast::Logger
Defined in:
src/lib/bootloader/bls_sections.rb

Overview

Represents available sections and handling of default BLS boot entry

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBlsSections

Returns a new instance of BlsSections.



25
26
27
28
29
30
# File 'src/lib/bootloader/bls_sections.rb', line 25

def initialize
  textdomain "bootloader"

  @all = []
  @default = ""
end

Instance Attribute Details

#allArray<String> (readonly)

or an empty array

Returns:

  • (Array<String>)

    list of all available boot titles



20
21
22
# File 'src/lib/bootloader/bls_sections.rb', line 20

def all
  @all
end

#defaultString

Returns title of default boot section.

Returns:

  • (String)

    title of default boot section.



23
24
25
# File 'src/lib/bootloader/bls_sections.rb', line 23

def default
  @default
end

Instance Method Details

#readObject



55
56
57
58
59
60
61
62
# File 'src/lib/bootloader/bls_sections.rb', line 55

def read
  @data = read_entries
  @all = @data.map { |e| e["title"] if e["type"] == "type1" }.compact
  file = Bls.default_menu.strip
  set = @data.find { |d| d["id"] == file }
  set ||= @data.first
  @default = set["title"] if set
end

#writeObject

writes default to system making it persistent



48
49
50
51
52
53
# File 'src/lib/bootloader/bls_sections.rb', line 48

def write
  return if @default.empty?

  set = @data.find { |d| d["title"] == @default }
  Bls.write_default_menu(set["id"]) if set
end