class Docks::Languages::CoffeeScript

Public Class Methods

extensions() click to toggle source
# File lib/docks/languages/coffeescript_language.rb, line 8
def self.extensions; %w(coffee coffeescript) end
type() click to toggle source
# File lib/docks/languages/coffeescript_language.rb, line 7
def self.type; Docks::Types::Languages::SCRIPT end

Public Instance Methods

parser() click to toggle source
# File lib/docks/languages/coffeescript_language.rb, line 10
def parser; Docks::Parsers::CoffeeScript.instance end
signature_for(symbol) click to toggle source
# File lib/docks/languages/coffeescript_language.rb, line 12
def signature_for(symbol)
  is_class = symbol.symbol_type == Types::Symbol::CLASS
  return unless is_class || [Types::Symbol::MIXIN, Types::Symbol::FUNCTION, Types::Symbol::FACTORY].include?(symbol.symbol_type)
  params = symbol.fetch(:params, [])

  presentation = if is_class
    "class #{symbol.name}\n  constructor: "
  elsif symbol.respond_to?(:method?) && symbol.method?
    symbol.static? ? "#{symbol.for}.#{symbol.name} = " : "#{symbol.name}: "
  else
    "#{symbol.name} = "
  end

  presentation << "(#{params.map { |param| "#{param.name}#{" = #{param.default}" if param.default}" }.join(", ")}) " unless params.empty?
  "#{presentation}-> # ..."
end