Class: Mulang::Language::External

Inherits:
Object
  • Object
show all
Defined in:
lib/mulang/language.rb

Instance Method Summary collapse

Constructor Details

#initialize(&tool) ⇒ External

Returns a new instance of External.



28
29
30
# File 'lib/mulang/language.rb', line 28

def initialize(&tool)
  @tool = block_given? ? tool : proc { |it| it }
end

Instance Method Details

#ast(content) ⇒ Object



32
33
34
# File 'lib/mulang/language.rb', line 32

def ast(content)
  @tool.call(content) rescue nil
end

#sample(content) ⇒ Object



36
37
38
39
40
41
# File 'lib/mulang/language.rb', line 36

def sample(content)
  {
    tag: 'MulangSample',
    ast: ast(content)
  }
end