Class: Antelope::DSL::Contexts::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/antelope/dsl/contexts/base.rb

Overview

The base context, which implements some helper methods.

Direct Known Subclasses

Main, Match, Precedence, Production, Terminal

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Base

Returns a new instance of Base.



8
9
10
11
# File 'lib/antelope/dsl/contexts/base.rb', line 8

def initialize(options)
  @options = options
  @contexts = Hash.new { |h, k| h[k] = k.new(@options) }
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/antelope/dsl/contexts/base.rb', line 6

def options
  @options
end

Instance Method Details

#before_callObject



23
# File 'lib/antelope/dsl/contexts/base.rb', line 23

def before_call; end

#call(&block) ⇒ Object



13
14
15
16
17
# File 'lib/antelope/dsl/contexts/base.rb', line 13

def call(&block)
  before_call
  instance_exec(self, &block)
  data
end

#context(name, &block) ⇒ Object



19
20
21
# File 'lib/antelope/dsl/contexts/base.rb', line 19

def context(name, &block)
  @contexts[name].call(&block)
end

#dataObject



25
# File 'lib/antelope/dsl/contexts/base.rb', line 25

def data; end