Class: Mulang::Language::Native

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

Instance Method Summary collapse

Constructor Details

#initialize(language) ⇒ Native

Returns a new instance of Native.



3
4
5
# File 'lib/mulang/language.rb', line 3

def initialize(language)
  @language = language
end

Instance Method Details

#ast(content) ⇒ Object



7
8
9
# File 'lib/mulang/language.rb', line 7

def ast(content)
  Mulang.analyse(ast_analysis(content))['intermediateLanguage'] rescue nil
end

#ast_analysis(content) ⇒ Object



11
12
13
14
15
16
# File 'lib/mulang/language.rb', line 11

def ast_analysis(content)
  {
    sample: { tag: 'CodeSample', language: @language, content: content },
    spec: { expectations: [], smellsSet: { tag: 'NoSmells' }, includeIntermediateLanguage: true }
  }
end

#sample(content) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/mulang/language.rb', line 18

def sample(content)
  {
    tag: 'CodeSample',
    language: @language,
    content: content
  }
end