Class: Conflisp::DSL

Inherits:
Object
  • Object
show all
Defined in:
lib/conflisp/dsl.rb

Overview

A nice helper DSL for building up Conflisp languages

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(registry:) ⇒ DSL

Returns a new instance of DSL.



15
16
17
# File 'lib/conflisp/dsl.rb', line 15

def initialize(registry:)
  @registry = registry
end

Instance Attribute Details

#registryObject (readonly)

Returns the value of attribute registry.



6
7
8
# File 'lib/conflisp/dsl.rb', line 6

def registry
  @registry
end

Class Method Details

.define(&block) ⇒ Object



8
9
10
11
12
13
# File 'lib/conflisp/dsl.rb', line 8

def self.define(&block)
  registry = {}
  dsl = new(registry: registry)
  dsl.instance_exec(&block)
  registry
end

Instance Method Details

#fn(name, implementation) ⇒ Object



19
20
21
# File 'lib/conflisp/dsl.rb', line 19

def fn(name, implementation)
  registry[name.to_s] = implementation
end