Class: Levels::Input::Ruby

Inherits:
Object
  • Object
show all
Defined in:
lib/levels/input/ruby.rb

Overview

This input provides a DSL for writing levels in ruby.

Defined Under Namespace

Classes: DSL

Instance Method Summary collapse

Constructor Details

#initialize(ruby_string, file = "Code in Memory", line = 1) ⇒ Ruby

Returns a new instance of Ruby.



6
7
8
9
10
# File 'lib/levels/input/ruby.rb', line 6

def initialize(ruby_string, file = "Code in Memory", line = 1)
  @ruby_string = ruby_string
  @file = file
  @line = line
end

Instance Method Details

#read(level) ⇒ Object



12
13
14
15
16
# File 'lib/levels/input/ruby.rb', line 12

def read(level)
  dsl = DSL.new(level)
  dsl.instance_eval(@ruby_string, @file, @line)
  dsl.close_current_group
end