Class: Command::RecordingInterpreter::Complete

Inherits:
Event
  • Object
show all
Defined in:
lib/command-set/interpreter/recording.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(buffer, prefix, result) ⇒ Complete

Returns a new instance of Complete.



15
16
17
# File 'lib/command-set/interpreter/recording.rb', line 15

def initialize(buffer, prefix, result)
  @buffer, @prefix, @result = buffer, prefix, result
end

Instance Attribute Details

#bufferObject (readonly)

Returns the value of attribute buffer.



19
20
21
# File 'lib/command-set/interpreter/recording.rb', line 19

def buffer
  @buffer
end

#prefixObject (readonly)

Returns the value of attribute prefix.



19
20
21
# File 'lib/command-set/interpreter/recording.rb', line 19

def prefix
  @prefix
end

#resultObject (readonly)

Returns the value of attribute result.



19
20
21
# File 'lib/command-set/interpreter/recording.rb', line 19

def result
  @result
end

Instance Method Details

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/command-set/interpreter/recording.rb', line 21

def eql?(other)
  return (self.buffer.eql?(other.buffer) and self.prefix.eql?(other.prefix))
end

#playback(prompt, interpreter, previous) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/command-set/interpreter/recording.rb', line 25

def playback(prompt, interpreter, previous)
  complete_list = interpreter.readline_complete(@buffer, @prefix)
  if complete_list.nil?
    puts prompt + @buffer + "<TAB>"
    puts
  elsif complete_list.length > 1 
    if previous.eql?(self)
      puts "<TAB>"
      complete_list.map{|item| item.ljust(15)}.each_slice(5) do|cons|
        puts cons.join
      end
    else
      print "\n" + prompt + @buffer + "<TAB>"
    end
  else
    puts "\n" + prompt + @buffer + "<TAB>"
    complete_list.map{|item| item.ljust(15)}.each_slice(5) do|cons|
      puts cons.join
    end
  end
end