Class: Trith::Compiler::Ruby
- Inherits:
- show all
- Defined in:
- lib/trith/compiler/ruby.rb
Overview
A Trith-to-Ruby compiler.
Constant Summary
- SHEBANG =
"#!/usr/bin/env ruby -rubygems"
Instance Method Summary (collapse)
- - emit(line) protected
-
- (Ruby) initialize(options = {})
constructor
A new instance of Ruby.
- - (String) to_s
Methods inherited from
compile, #compile, compile_files, #compile_operand, for
Constructor Details
- (Ruby) initialize(options = {})
A new instance of Ruby
9 10 11 12 13 |
# File 'lib/trith/compiler/ruby.rb', line 9 def initialize( = {}) super() @options[:shebang] ||= SHEBANG @output = StringIO.new end |
Instance Method Details
- emit(line) (protected)
This method returns an undefined value.
88 89 90 |
# File 'lib/trith/compiler/ruby.rb', line 88 def emit(line) @output.puts(" " << line.to_s) end |
- (String) to_s
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/trith/compiler/ruby.rb', line 17 def to_s output = StringIO.new output.puts @options[:shebang] output.puts "require 'rubygems'" if @options[:rubygems] output.puts "require 'trith'" output.puts output.puts "Trith::Machine.run(ARGV) do" output.write @output.string output.puts "end" output.string end |