Class: GitHub::Markup::Implementation
- Inherits:
-
Object
- Object
- GitHub::Markup::Implementation
- Defined in:
- lib/github/markup/implementation.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#languages ⇒ Object
readonly
Returns the value of attribute languages.
-
#regexp ⇒ Object
readonly
Returns the value of attribute regexp.
Instance Method Summary collapse
-
#initialize(regexp, languages) ⇒ Implementation
constructor
A new instance of Implementation.
- #load ⇒ Object
- #match?(filename, language) ⇒ Boolean
- #render(filename, content, options: {}) ⇒ Object
Constructor Details
#initialize(regexp, languages) ⇒ Implementation
Returns a new instance of Implementation.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/github/markup/implementation.rb', line 7 def initialize(regexp, languages) @regexp = regexp if defined?(::Linguist) @languages = languages.map do |l| lang = Linguist::Language[l] raise "no match for language #{l.inspect}" if lang.nil? lang end end end |
Instance Attribute Details
#languages ⇒ Object (readonly)
Returns the value of attribute languages.
5 6 7 |
# File 'lib/github/markup/implementation.rb', line 5 def languages @languages end |
#regexp ⇒ Object (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
#load ⇒ Object
19 20 21 |
# File 'lib/github/markup/implementation.rb', line 19 def load # no-op by default end |
#match?(filename, language) ⇒ Boolean
27 28 29 30 31 32 33 |
# File 'lib/github/markup/implementation.rb', line 27 def match?(filename, language) if defined?(::Linguist) languages.include? language else file_ext_regexp =~ filename end end |
#render(filename, content, options: {}) ⇒ Object
23 24 25 |
# File 'lib/github/markup/implementation.rb', line 23 def render(filename, content, options: {}) raise NotImplementedError, "subclasses of GitHub::Markup::Implementation must define #render" end |