Class: Linux::Lxc::Line
- Inherits:
-
Object
- Object
- Linux::Lxc::Line
- Defined in:
- lib/linux/lxc/line.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#lxc ⇒ Object
readonly
Returns the value of attribute lxc.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #comment! ⇒ Object
- #file ⇒ Object
-
#initialize(lxc, key, value) ⇒ Line
constructor
A new instance of Line.
- #to_s ⇒ Object
Constructor Details
#initialize(lxc, key, value) ⇒ Line
Returns a new instance of Line.
6 7 8 9 10 11 |
# File 'lib/linux/lxc/line.rb', line 6 def initialize(lxc, key, value) @lxc = lxc @line = lxc && lxc.lines.add(self).length @key = key @value = value end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
4 5 6 |
# File 'lib/linux/lxc/line.rb', line 4 def key @key end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
4 5 6 |
# File 'lib/linux/lxc/line.rb', line 4 def line @line end |
#lxc ⇒ Object (readonly)
Returns the value of attribute lxc.
4 5 6 |
# File 'lib/linux/lxc/line.rb', line 4 def lxc @lxc end |
#value ⇒ Object
Returns the value of attribute value.
5 6 7 |
# File 'lib/linux/lxc/line.rb', line 5 def value @value end |
Instance Method Details
#comment! ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/linux/lxc/line.rb', line 17 def comment! return if @key == '#' # remove from index lxc.remove_from_index(self) uncomment = to_s @key = '#' @value = '# ' + uncomment lxc.add_to_index(self) end |
#file ⇒ Object
13 14 15 |
# File 'lib/linux/lxc/line.rb', line 13 def file @lxc.file end |
#to_s ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/linux/lxc/line.rb', line 27 def to_s if value if key == '#' value else "#{key} = #{value}" end else key end end |