Class: Rosette::Core::StaticExtractor
- Inherits:
-
Object
- Object
- Rosette::Core::StaticExtractor
- Defined in:
- lib/rosette/core/extractor/static_extractor.rb
Overview
Base class for extractors that extract entries from flat files, eg. XML, YAML, json, etc.
Instance Attribute Summary collapse
-
#config ⇒ Configurator
readonly
The Rosette config to use.
Instance Method Summary collapse
-
#extract_each_from(file_contents) {|phrase| ... } ⇒ void, Enumerator
Extracts each translatable phrase from the given flat file contents.
-
#initialize(config = nil) ⇒ StaticExtractor
constructor
Creates a new extractor.
Constructor Details
#initialize(config = nil) ⇒ StaticExtractor
Creates a new extractor.
17 18 19 |
# File 'lib/rosette/core/extractor/static_extractor.rb', line 17 def initialize(config = nil) @config = config end |
Instance Attribute Details
#config ⇒ Configurator (readonly)
Returns the Rosette config to use.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rosette/core/extractor/static_extractor.rb', line 11 class StaticExtractor attr_reader :config # Creates a new extractor. # # @param [Configurator] config The Rosette config to use. def initialize(config = nil) @config = config end # Extracts each translatable phrase from the given flat file # contents. Must be implemented by derived classes # # @param [String] file_contents The flat file contents to extract # phrases from. # @return [void, Enumerator] If passed a block, this method yields # each consecutive phrase found in +file_contents+. If no block is # passed, it returns an +Enumerator+. # @yield [phrase] a single extracted phrase. # @yieldparam phrase [Phrase] def extract_each_from(file_contents) raise NotImplementedError, "#{__method__} must be implemented by derived classes." end protected def make_phrase(key, = nil, file = nil) Phrase.new(key, , file) end end |
Instance Method Details
#extract_each_from(file_contents) {|phrase| ... } ⇒ void, Enumerator
Extracts each translatable phrase from the given flat file contents. Must be implemented by derived classes
31 32 33 34 |
# File 'lib/rosette/core/extractor/static_extractor.rb', line 31 def extract_each_from(file_contents) raise NotImplementedError, "#{__method__} must be implemented by derived classes." end |