Class: PutText::Parser::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/puttext/parser/base.rb

Direct Known Subclasses

Ruby

Instance Method Summary collapse

Instance Method Details

#strings_from_file(path) ⇒ Array<POEntry>

Parse gettext strings from a file in the path.

Parameters:

  • path (String)

    the path of the file to parse.

Returns:

  • (Array<POEntry>)

    an array of POEntry objects extracted from the given file.



12
13
14
# File 'lib/puttext/parser/base.rb', line 12

def strings_from_file(path)
  strings_from_source(File.read(path), filename: path)
end

#strings_from_source(source, opts) ⇒ Array<POEntry>

Parse gettext strings from a given snippet of source code.

Parameters:

  • source (String)

    the snippet of source code to parse.

  • opts (Hash)

Options Hash (opts):

  • :filename (String)

    path of the file being parsed. Defaults to “(string)”.

  • :first_line (Integer)

    number of the first line being parsed. Defaults to 1.

Returns:

  • (Array<POEntry>)

    an array of POEntry objects extracted from the given source code.



# File 'lib/puttext/parser/base.rb', line 16