Flowdock
method

detect_magic_comment

Importance_0
Ruby latest stable (v2_5_5) - 0 notes - Class: ERB::Compiler
detect_magic_comment(s, enc = nil) private

No documentation

This method has no description. You can help the Ruby community by adding new notes.

Hide source
# File lib/erb.rb, line 721
    def detect_magic_comment(s, enc = nil)
      re = @percent ? /\G(?:<%#(.*)%>|%#(.*)\n)/ : /\G<%#(.*)%>/
      frozen = nil
      s.scan(re) do
        comment = $+
        comment = $1 if comment[/-\*-\s*(.*?)\s*-*-$/]
        case comment
        when %coding\s*[=:]\s*([[:alnum:]\-_]+)"
          enc = Encoding.find($1.sub(/-(?:mac|dos|unix)/, ''))
        when %frozen[-_]string[-_]literal\s*:\s*([[:alnum:]]+)"
          frozen = $1
        end
      end
      return enc, frozen
    end
Register or log in to add new notes.