Class: Coursemology::Polyglot::Language

Inherits:
ActiveRecord::Base
  • Object
show all
Extended by:
ActiveSupport::Autoload
Defined in:
lib/coursemology/polyglot/language.rb,
lib/coursemology/polyglot/language.rb,
lib/coursemology/polyglot/language.rb

Overview

An abstract language. This is a class which can represent a family of languages. Languages become concrete and can be used when that language includes Coursemology::Polyglot::ConcreteLanguage.

Languages define their own scripts and stylesheets needed to syntax highlight code.

Each subclass represents a language ancestry, such as differing language versions (see the Python language definition.) Derived languages can be defined at runtime to utilise the syntax highlighting capabilities of the root language, while requiring a separate runtime environment to run programs written in the derived language.

Do NOT remove languages after they have been defined because the types specified in this library can have references stored in code (e.g. in a database)

Direct Known Subclasses

CPlusPlus, Java, JavaScript, Python

Defined Under Namespace

Classes: CPlusPlus, Java, JavaScript, Python

Class Method Summary collapse

Class Method Details

.ace_modeString

This method is abstract.

The Ace mode to use with this language.

Returns:



108
109
110
# File 'lib/coursemology/polyglot/language.rb', line 108

def self.ace_mode
  fail NotImplementedError
end

.concrete_languagesArray<Class>

Determines the concrete language subclasses of this language.

Returns:



57
58
59
60
61
# File 'lib/coursemology/polyglot/language.rb', line 57

def self.concrete_languages
  descendants.select do |klass|
    klass.ancestors.include?(Coursemology::Polyglot::ConcreteLanguage)
  end
end

.display_nameString

This method is abstract.

Gets the display name of the language.

Returns:



92
93
94
# File 'lib/coursemology/polyglot/language.rb', line 92

def self.display_name
  fail NotImplementedError
end

.rouge_lexerString

This method is abstract.

The Rouge lexer to use with this language.

Returns:



100
101
102
# File 'lib/coursemology/polyglot/language.rb', line 100

def self.rouge_lexer
  fail NotImplementedError
end