Class: Mysh::StringSource

Inherits:
Object show all
Defined in:
lib/mysh/sources/string.rb

Overview

A wrapper for a string with mysh commands.

Instance Method Summary collapse

Constructor Details

#initialize(str) ⇒ StringSource

Setup the string source.



10
11
12
13
# File 'lib/mysh/sources/string.rb', line 10

def initialize(str)
  @eoi = false
  @read_pt = str.lines.each
end

Instance Method Details

#eoi?Boolean

Have we reached the end of input?

Returns:

  • (Boolean)


27
28
29
# File 'lib/mysh/sources/string.rb', line 27

def eoi?
  @eoi
end

#get_command(_str = "") ⇒ Object Also known as: get_command_extra

Get the initial line of command input.



16
17
18
19
20
21
# File 'lib/mysh/sources/string.rb', line 16

def get_command(_str="")
  @read_pt.next
rescue StopIteration
  @eoi = true
  "\n"
end