Class: GenMachine::Generators::RubyGenerator

Inherits:
Object
  • Object
show all
Includes:
Generator, Helpers::General, Helpers::Ruby
Defined in:
lib/genmachine/generators/ruby/ruby.rb

Constant Summary collapse

GENMACHINE_TARGET =
'ruby'

Constants included from Helpers::Ruby

Helpers::Ruby::INPUT, Helpers::Ruby::STATE

Instance Method Summary collapse

Methods included from Helpers::General

#accumulates?, #accumulators, #eof_clause?, #eof_state?, #makes_calls?

Methods included from Helpers::Ruby

#rb_acc_commands, #rb_charset_cond, #rb_commands, #rb_conditional, #rb_simple_acc_commands, #rb_transition_commands, #rb_vars

Methods included from Generator

#run_test

Constructor Details

#initialize(opts) ⇒ RubyGenerator

Returns a new instance of RubyGenerator.



13
14
15
16
# File 'lib/genmachine/generators/ruby/ruby.rb', line 13

def initialize(opts)
  @template_base = File.dirname(__FILE__) + '/'
  super(opts)
end

Instance Method Details

#generate_classObject



18
19
20
21
22
23
# File 'lib/genmachine/generators/ruby/ruby.rb', line 18

def generate_class
  library = ERB.new(IO.read(@template_base+'lib.erb.rb'),nil,'-')
  f = File.new(File.join(@output_dir,@class_fname), 'w+')
  f.write(library.result(binding))
  f.close
end

#generate_executableObject



25
26
27
28
29
30
31
32
# File 'lib/genmachine/generators/ruby/ruby.rb', line 25

def generate_executable
  return unless @gen_executable
  executable = ERB.new(IO.read(@template_base+'executable.erb'),nil,'-')
  f = File.new(File.join(@output_dir,@exe_fname), 'w+')
  f.write(executable.result(binding))
  f.chmod(0755)
  f.close
end