Class: DevSystem::LineShell

Inherits:
Shell show all
Defined in:
lib/dev_system/sub/shell/shells/line_shell.rb

Class Method Summary collapse

Methods inherited from Shell

cruby?, engine, jruby?, linux?, mac?, os, ruby_version, unix?, windows?

Methods inherited from Liza::Controller

color, inherited, on_connected

Methods inherited from Liza::Unit

const_missing, division, part, system, #system, test_class

Class Method Details

.extract_wall_of(lines, string) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/dev_system/sub/shell/shells/line_shell.rb', line 5

def self.extract_wall_of(lines, string)
  ret = []

  state = nil
  lines.each do |line|
    if state == :entered_region
      if line.start_with? string
        ret << line
      else
        break
      end
    else
      if line.start_with? string
        state = :entered_region
        ret << line
      end
    end
  end

  ret
end

.replace_wall_of(lines, string, with) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/dev_system/sub/shell/shells/line_shell.rb', line 29

def self.replace_wall_of(lines, string, with)
  ret = []
  
  state = nil
  lines.each do |line|

    if state == :entered_region
      if line.start_with? string
        #
      else
        ret << line
        state = nil
      end
    else
      if line.start_with? string
        ret += with
        state = :entered_region
      else
        ret << line
      end
    end

  end

  ret
end