Class: CFA::Grub2::Default::KernelParams::ParamTree
- Inherits:
-
Object
- Object
- CFA::Grub2::Default::KernelParams::ParamTree
- Defined in:
- lib/cfa/grub2/default.rb
Overview
Represents parsed kernel parameters tree. Parses in initialization and backserilized by ‘to_string`. TODO: replace it via augeas parser when someone write lense
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
-
#initialize(line) ⇒ ParamTree
constructor
A new instance of ParamTree.
- #to_string ⇒ Object
Constructor Details
#initialize(line) ⇒ ParamTree
Returns a new instance of ParamTree.
204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/cfa/grub2/default.rb', line 204 def initialize(line) 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 } end end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
202 203 204 |
# File 'lib/cfa/grub2/default.rb', line 202 def data @data end |
Instance Method Details
#to_string ⇒ Object
218 219 220 221 222 223 224 225 226 227 228 |
# File 'lib/cfa/grub2/default.rb', line 218 def to_string snippets = @data.map do |e| if e[:value] == true e[:key] else "#{e[:key]}=#{e[:value]}" end end snippets.join(" ") end |