Class: FAQML::Parser Private
- Inherits:
-
Object
- Object
- FAQML::Parser
- Includes:
- Temple::Mixins::Options
- Defined in:
- lib/fml/parser.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Transforms FML into a Temple expression
Defined Under Namespace
Classes: SyntaxError
Instance Method Summary collapse
-
#call(str) ⇒ Array
private
Compile string to Temple expression.
-
#initialize(options = {}) ⇒ Parser
constructor
private
A new instance of Parser.
Constructor Details
#initialize(options = {}) ⇒ Parser
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Parser.
31 32 33 34 |
# File 'lib/fml/parser.rb', line 31 def initialize( = {}) super @tab = ' ' * @options[:tabsize] end |
Instance Method Details
#call(str) ⇒ Array
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Compile string to Temple expression
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/fml/parser.rb', line 40 def call(str) # Set string encoding if option is set if [:encoding] && str.respond_to?(:encoding) old_enc = str.encoding str = str.dup if str.frozen? str.force_encoding([:encoding]) # Fall back to old encoding if new encoding is invalid str.force_encoding(old_enc) unless str.valid_encoding? end result = [:multi] reset(str.split(/\r?\n/), result) parse_line while next_line reset result end |