class GetText::ErbParser

Constants

MAGIC_COMMENT

Public Class Methods

new(path, options={}) click to toggle source

@param path [String] eRuby script path to be parsed @param options [Hash]

# File lib/gettext/tools/parser/erb.rb, line 54
def initialize(path, options={})
  @path = path
  @options = options
end

Public Instance Methods

detect_encoding(erb_source) click to toggle source
# File lib/gettext/tools/parser/erb.rb, line 77
def detect_encoding(erb_source)
  if /\A#coding:(.*)\n/ =~ erb_source
    $1
  else
    nil
  end
end
init(config) click to toggle source

Sets some preferences to parse ERB files.

  • config: a Hash of the config. It can takes some values below:

    • :extnames: An Array of target files extension. Default is [“.rhtml”].

# File lib/gettext/tools/parser/erb.rb, line 24
def init(config)
  config.each{|k, v|
    @config[k] = v
  }
end
parse(path, options={}) click to toggle source

Parses eRuby script located at `path`.

This is a short cut method. It equals to `new(path, options).parse`.

@return [Array<POEntry>] Extracted messages @see initialize and parse

# File lib/gettext/tools/parser/erb.rb, line 44
def parse(path, options={})
  parser = new(path, options)
  parser.parse
end