Class: Rust
- Inherits:
-
Object
- Object
- Rust
- Defined in:
- lib/rust/rust.rb
Class Method Summary collapse
-
.io ⇒ Object
Used by the parser.
Instance Method Summary collapse
-
#initialize(stdin = $stdin, stdout = $stdout, stderr = $stderr) ⇒ Rust
constructor
A new instance of Rust.
- #prompt ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(stdin = $stdin, stdout = $stdout, stderr = $stderr) ⇒ Rust
Returns a new instance of Rust.
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rust/rust.rb', line 36 def initialize(stdin=$stdin, stdout=$stdout, stderr=$stderr) $stdin, $stdout, $stderr = stdin, stdout, stderr $keys ||= {} @history = [] @io = InOut.new(stdin, stdout, stderr, $keys) @@io = @io # a nice hack for parser compatiblity run end |
Class Method Details
.io ⇒ Object
Used by the parser
32 33 34 |
# File 'lib/rust/rust.rb', line 32 def self.io @@io end |
Instance Method Details
#prompt ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/rust/rust.rb', line 60 def prompt line = '' loop { line += ask($prompt) # unless line.slice(-1) =~ /\\/ @history << line $parser.execute line.strip unless line.strip =~ /^$/ # $parser.execute line line = '' # end } end |
#run ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/rust/rust.rb', line 47 def run ###### ## Read the user's .rustrc file if File.exist? "#{ENV['HOME']}/.rustrc" CommandCenter.instance_eval(File.read("#{ENV['HOME']}/.rustrc")) else File.open("#{ENV['HOME']}/.rustrc", 'w') end prompt end |