Class: Linux::Lxc::Line

Inherits:
Object
  • Object
show all
Defined in:
lib/linux/lxc.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lxc, key, value) ⇒ Line

Returns a new instance of Line.



9
10
11
12
13
14
# File 'lib/linux/lxc.rb', line 9

def initialize(lxc, key, value)
  @lxc = lxc
  @line = lxc && lxc.lines.add(self).length
  @key = key
  @value = value
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



7
8
9
# File 'lib/linux/lxc.rb', line 7

def key
  @key
end

#lineObject (readonly)

Returns the value of attribute line.



7
8
9
# File 'lib/linux/lxc.rb', line 7

def line
  @line
end

#lxcObject (readonly)

Returns the value of attribute lxc.



7
8
9
# File 'lib/linux/lxc.rb', line 7

def lxc
  @lxc
end

#valueObject

Returns the value of attribute value.



8
9
10
# File 'lib/linux/lxc.rb', line 8

def value
  @value
end

Instance Method Details

#comment!Object



18
19
20
21
22
23
24
25
# File 'lib/linux/lxc.rb', line 18

def comment!
  return if @key == '#'
  # remove from index
  lxc.remove_from_index(self)
  @key = '#'
  @value = '# ' + self.to_s
  lxc.add_to_index(self)
end

#fileObject



15
16
17
# File 'lib/linux/lxc.rb', line 15

def file
  @lxc.file
end

#to_sObject



26
27
28
29
30
31
32
# File 'lib/linux/lxc.rb', line 26

def to_s
  if value
    "#{key} = #{value}"
  else
    key
  end
end