class GetText::MoteParser
Constants
- VERSION
Public Class Methods
init(config)
click to toggle source
Sets some preferences to parse Mote files.
-
config: a Hash of the config. It can takes some values below:
-
:extnames: An Array of target files extension. Default is [“.mote”].
-
# File lib/gettext/mote_parser/mote_parser.rb, line 16 def init(config) config.each do |k, v| @config[k] = v end end
new(path, options = {})
click to toggle source
@param path [String] Mote script path to be parsed @param options [Hash]
# File lib/gettext/mote_parser/mote_parser.rb, line 44 def initialize(path, options = {}) @path = path @options = options end
parse(path, options = {})
click to toggle source
Parses Mote 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/mote_parser/mote_parser.rb, line 36 def parse(path, options = {}) parser = new(path, options) parser.parse end
Public Instance Methods
parse()
click to toggle source
Extracts messages from @path.
@return [Array<POEntry>] Extracted messages
# File lib/gettext/mote_parser/mote_parser.rb, line 52 def parse content = IO.read(@path) src = Mote.src(content) # Force the src encoding back to the original encoding. src.force_encoding(content.encoding) RubyParser.new(@path, @options).parse_source(src) end