class CFA::Grub2::Default::KernelParams::ParamTree
Represents parsed kernel parameters tree. Parses in initialization and backserilized by `to_string`. TODO: replace it via augeas parser when someone write lense
Public Class Methods
new(line)
click to toggle source
# File lib/cfa/grub2/default.rb, line 236 def initialize(line) pairs = (line || "").split(/\s/) .reject(&:empty?) .map { |e| e.split("=", 2) } @data = pairs.map do |k, v| { key: k, value: v || true, # kernel param without value have true operation: :keep } end end
Public Instance Methods
all_data()
click to toggle source
# File lib/cfa/grub2/default.rb, line 266 def all_data @data end
data()
click to toggle source
# File lib/cfa/grub2/default.rb, line 262 def data @data.reject { |e| e[:operation] == :remove }.freeze end
to_string()
click to toggle source
# File lib/cfa/grub2/default.rb, line 250 def to_string snippets = data.map do |e| if e[:value] == true e[:key] else "#{e[:key]}=#{e[:value]}" end end snippets.join(" ") end