Class: Rbml::Cli

Inherits:
Base
  • Object
show all
Defined in:
lib/cli.rb

Instance Attribute Summary

Attributes inherited from Base

#dsl

Class Method Summary collapse

Methods inherited from Base

#initialize, #instance_eval_each

Constructor Details

This class inherits a constructor from Rbml::Base

Class Method Details

.render(language, options, &block) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/cli.rb', line 3

def self.render(language, options, &block)
  d = Cli.new(language)
  display = lambda { |result| result }
  loop do
    begin
      printf options[:prompt]
      d.instance_eval_each(block, &display) 
      obj = IO.new(0, "w+")
      args = obj.gets.split
      d.dsl.__send__("call", *args) unless args.empty?
    rescue Interrupt
      puts "\nExiting #{options[:name]}..."
      break
    end
  end
end