Sha256: d0de39c579994136449eb59459d7674167c222a19cb406ebcab77b280f5a600c
Contents?: true
Size: 869 Bytes
Versions: 2
Compression:
Stored size: 869 Bytes
Contents
module Lomic class LomicParser def initialize # points to the Rule that is currently being parsed @currentRule = nil # The entire state of the game @state = GameState.new @first_rule = true end def rule(number) # TODO: ensure number is int @currentRule = Rule.new(number) if @first_rule @state.globals = instance_eval 'Globals.new' @first_rule = false end yield @state.globals ensure @state.addRule(@currentRule) @currentRule = nil end def event(event_name, options={}, &block) @currentRule.event(event_name, options, &block) end def gamestate @state end def self.load_source(filename) dsl = new dsl.instance_eval(File.read(filename),filename) # dsl.gamestate.globals = (dsl.instance_eval 'Globals.new') dsl.gamestate end end end # module
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
lomic-0.0.2 | lib/lomic/LomicParser.rb |
lomic-0.0.1 | lib/lomic/LomicParser.rb |