Module: Edit
Constant Summary
Constants included from Operations
Operations::Operand, Operations::Operator
Instance Method Summary collapse
Methods included from Operations
#process_operation, #process_operations
Instance Method Details
#edit(node, linearg = nil) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 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 55 56 57 58 59 60 61 62 |
# File 'lib/edit.rb', line 17 def edit node, linearg = nil @node = node @nodes[node] = [] if not @nodes[node] save run = true while run header node if linearg line = linearg else line = readline end line redo if line["%"] exit unless line if line == "#" @msg = "" @raw = @raw.! if @raw @prompt = " # ".col 'blue' else @prompt = "<> ".col("cyan", "black") end elsif process_operations(line) msg "" edit node unless linearg else @msg = "" save if line != "" if @nodes[node].find_index(line) and not @raw and not linearg @path << node edit line unless linearg else ins node, line end elsif not linearg back node end end save break if linearg end end |
#expand(line) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/edit.rb', line 6 def line return unless line["%"] regex = Regexp.new Readline.readline "regulair expression: ".col("cyan") @nodes[@node].collect{|n| n if n == n[regex] }.compact.each {|m| edit(@node, line.sub("%", m)) } end |