Class: CI::Syntax::Tool::LanguageFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/ci-syntax-tool/language_factory.rb

Overview

CI:Syntax::Tool::LanguageFactory

Identifies and loads the Language classes, and

creates instances as needed.

Class Method Summary collapse

Class Method Details

.all_language_classesObject



18
19
20
# File 'lib/ci-syntax-tool/language_factory.rb', line 18

def self.all_language_classes
  Language::Base.descendant_classes
end

.all_language_namesObject



22
23
24
25
26
27
28
# File 'lib/ci-syntax-tool/language_factory.rb', line 22

def self.all_language_names
  class_names = all_language_classes.map(&:name)
  short_names = class_names.map do |name|
    name.split('::').last
  end
  short_names
end

.create(lang_name, args = {}) ⇒ Object



34
35
36
# File 'lib/ci-syntax-tool/language_factory.rb', line 34

def self.create(lang_name, args = {})
  const_get('CI::Syntax::Tool::Language::' + lang_name).new(args)
end

.valid_language?(proposed) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/ci-syntax-tool/language_factory.rb', line 30

def self.valid_language?(proposed)
  all_language_names.include?(proposed)
end