Class: Yast::SummaryClass

Inherits:
Module
  • Object
show all
Defined in:
library/general/src/modules/Summary.rb

Instance Method Summary collapse

Instance Method Details

#AddHeader(summary, header) ⇒ String

Add a RichText section header to an existing summary.

Parameters:

  • summary (String)

    previous RichText (HTML) summary to add to

  • header (String)

    header to add (plain text, no HTML)

Returns:

  • (String)

    the new summary including the new header


106
107
108
# File 'library/general/src/modules/Summary.rb', line 106

def AddHeader(summary, header)
  Ops.add(Ops.add(Ops.add(summary, "<h3>"), header), "</h3>")
end

#AddLine(summary, line) ⇒ String

Add a line to an existing summary.

Parameters:

  • summary (String)

    previous RichText (HTML) summary to add to

  • line (String)

    line to add (plain text, no HTML)

Returns:

  • (String)

    the new summary including the new line


115
116
117
# File 'library/general/src/modules/Summary.rb', line 115

def AddLine(summary, line)
  Ops.add(Ops.add(Ops.add(summary, "<p>"), line), "</p>")
end

#AddListItem(summary, item) ⇒ String

Add a list item to an existing summary. Requires a previous call to 'summaryOpenList()'.

Parameters:

  • summary (String)

    previous RichText (HTML) summary to add to

  • item (String)

    item to add (plain text, no HTML)

Returns:

  • (String)

    the new summary including the new line


149
150
151
# File 'library/general/src/modules/Summary.rb', line 149

def AddListItem(summary, item)
  Ops.add(Ops.add(Ops.add(summary, "\n<li>"), item), "</li>")
end

#AddNewLine(summary) ⇒ String

Add a newline to an existing summary.

Parameters:

  • summary (String)

    previous RichText (HTML) summary to add to

Returns:

  • (String)

    the new summary


123
124
125
# File 'library/general/src/modules/Summary.rb', line 123

def AddNewLine(summary)
  Ops.add(summary, "<br>")
end

#AddSimpleSection(summary, header, item) ⇒ String

Add a simple section to an existing summary, consisting of a header and one single item.

Parameters:

  • summary (String)

    previous RichText (HTML) summary to add to

  • header (String)

    section header (plain text, no HTML)

  • item (String)

    section item (plain text, no HTML)

Returns:

  • (String)

    the new summary including the new line


160
161
162
163
164
165
166
167
# File 'library/general/src/modules/Summary.rb', line 160

def AddSimpleSection(summary, header, item)
  summary = AddHeader(summary, header)
  summary = OpenList(summary)
  summary = AddListItem(summary, item)
  summary = CloseList(summary)

  summary
end

#CloseList(summary) ⇒ String

End a list within a summary.

Parameters:

  • summary (String)

    previous RichText (HTML) summary to add to

Returns:

  • (String)

    the new summary


139
140
141
# File 'library/general/src/modules/Summary.rb', line 139

def CloseList(summary)
  Ops.add(summary, "</ul>")
end

#Device(name, description) ⇒ String

Function that creates description of one device.

Parameters:

  • name (String)

    The name of the device given by probing

  • description (String)

    Additional description (how it was confgured or so)

Returns:

  • (String)

    String with the item.


97
98
99
# File 'library/general/src/modules/Summary.rb', line 97

def Device(name, description)
  Builtins.sformat("<li><p>%1<br>%2</p></li>", name, description)
end

#DevicesList(devices) ⇒ String

Function that creates the whole final product. "Not detected" will be returned if the list is empty.

Parameters:

  • devices (Array<String>)

    A list of output of the summaryDevice() calls

Returns:

  • (String)

    The resulting text.


74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'library/general/src/modules/Summary.rb', line 74

def DevicesList(devices)
  devices = deep_copy(devices)
  text = ""
  if Builtins.size(devices) == 0
    text = if !Mode.config
      # translators: summary if no hardware was detected
      Builtins.sformat("<ul><li>%1</li></ul>", _("Not detected."))
    else
      Builtins.sformat("<ul><li>%1</li></ul>", NotConfigured())
    end
  else
    Builtins.foreach(devices) { |dev| text = Ops.add(text, dev) }
    text = Builtins.sformat("<ul>%1</ul>", text)
  end

  text
end

#mainObject


56
57
58
59
60
# File 'library/general/src/modules/Summary.rb', line 56

def main
  textdomain "base"

  Yast.import "Mode"
end

#NotConfiguredObject

Function that creates a 'Not configured.' message.

Returns:

  • String with the message.


64
65
66
67
# File 'library/general/src/modules/Summary.rb', line 64

def NotConfigured
  # translators: summary if the module has not been used yet in AutoYaST profile
  _("Not configured yet.")
end

#OpenList(summary) ⇒ String

Start a list within a summary.

Parameters:

  • summary (String)

    previous RichText (HTML) summary to add to

Returns:

  • (String)

    the new summary


131
132
133
# File 'library/general/src/modules/Summary.rb', line 131

def OpenList(summary)
  Ops.add(summary, "<ul>")
end