Class: Linux::Lxc::Lines

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

Instance Method Summary collapse

Constructor Details

#initializeLines

Returns a new instance of Lines.



4
5
6
# File 'lib/linux/lxc/lines.rb', line 4

def initialize
  @lines = []
end

Instance Method Details

#[](idx) ⇒ Object



33
34
35
# File 'lib/linux/lxc/lines.rb', line 33

def [](idx)
  @lines[idx]
end

#add(line) ⇒ Object



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

def add(line)
  @lines << line
  @lines
end

#comment!Object



37
38
39
# File 'lib/linux/lxc/lines.rb', line 37

def comment!
  @lines.each(&:comment!)
end

#each(&block) ⇒ Object



13
14
15
# File 'lib/linux/lxc/lines.rb', line 13

def each(&block)
  @lines.each { |line| block.call(line) }
end

#empty?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/linux/lxc/lines.rb', line 45

def empty?
  @lines.empty?
end

#find(&block) ⇒ Object



21
22
23
# File 'lib/linux/lxc/lines.rb', line 21

def find(&block)
  @lines.find(&block)
end

#firstObject



49
50
51
# File 'lib/linux/lxc/lines.rb', line 49

def first
  @lines.first
end

#lengthObject



41
42
43
# File 'lib/linux/lxc/lines.rb', line 41

def length
  @lines.length
end

#remove(line) ⇒ Object



29
30
31
# File 'lib/linux/lxc/lines.rb', line 29

def remove(line)
  @lines = @lines.select { |i| i != line }
end

#select(&block) ⇒ Object



17
18
19
# File 'lib/linux/lxc/lines.rb', line 17

def select(&block)
  @lines.select { |line| block.call(line) }
end

#valuesObject



25
26
27
# File 'lib/linux/lxc/lines.rb', line 25

def values
  @lines.map(&:value)
end