Class: GitHub::Markup::Implementation

Inherits:
Object
  • Object
show all
Defined in:
lib/github/markup/implementation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(regexp, languages) ⇒ Implementation

Returns a new instance of Implementation.



7
8
9
10
11
12
13
# File 'lib/github/markup/implementation.rb', line 7

def initialize(regexp, languages)
  @regexp = regexp

  if defined?(::Linguist)
    @languages = languages.map {|l| Linguist::Language[l]}
  end
end

Instance Attribute Details

#languagesObject (readonly)

Returns the value of attribute languages.



5
6
7
# File 'lib/github/markup/implementation.rb', line 5

def languages
  @languages
end

#regexpObject (readonly)

Returns the value of attribute regexp.



4
5
6
# File 'lib/github/markup/implementation.rb', line 4

def regexp
  @regexp
end

Instance Method Details

#loadObject



15
16
17
# File 'lib/github/markup/implementation.rb', line 15

def load
  # no-op by default
end

#match?(filename, language) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
26
27
28
29
# File 'lib/github/markup/implementation.rb', line 23

def match?(filename, language)
  if defined?(::Linguist)
    languages.include? language
  else
    file_ext_regexp =~ filename
  end
end

#render(filename, content) ⇒ Object

Raises:

  • (NotImplementedError)


19
20
21
# File 'lib/github/markup/implementation.rb', line 19

def render(filename, content)
  raise NotImplementedError, "subclasses of GitHub::Markup::Implementation must define #render"
end