Class: Fmt::EmbedParser
- Defined in:
- lib/fmt/parsers/embed_parser.rb
Overview
Parses embeds from a string and builds an AST (Abstract Syntax Tree)
Constant Summary
Constants inherited from Parser
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
: Symbol – key for embed.
-
#placeholder ⇒ Object
readonly
: String – placeholder for embed.
-
#urtext ⇒ Object
readonly
: String – original source code.
Instance Method Summary collapse
-
#initialize(urtext = "", key:, placeholder:) ⇒ EmbedParser
constructor
Constructor.
-
#parse ⇒ Object
Parses the urtext (original source code).
Methods inherited from Parser
Constructor Details
#initialize(urtext = "", key:, placeholder:) ⇒ EmbedParser
Constructor
12 13 14 15 16 |
# File 'lib/fmt/parsers/embed_parser.rb', line 12 def initialize(urtext = "", key:, placeholder:) @urtext = urtext.to_s.encode(Encoding::UTF_8, invalid: :replace, undef: :replace, replace: "?") @key = key @placeholder = placeholder end |
Instance Attribute Details
#key ⇒ Object (readonly)
: Symbol – key for embed
19 20 21 |
# File 'lib/fmt/parsers/embed_parser.rb', line 19 def key @key end |
#placeholder ⇒ Object (readonly)
: String – placeholder for embed
20 21 22 |
# File 'lib/fmt/parsers/embed_parser.rb', line 20 def placeholder @placeholder end |
#urtext ⇒ Object (readonly)
: String – original source code
18 19 20 |
# File 'lib/fmt/parsers/embed_parser.rb', line 18 def urtext @urtext end |
Instance Method Details
#parse ⇒ Object
Parses the urtext (original source code)
24 25 26 |
# File 'lib/fmt/parsers/embed_parser.rb', line 24 def parse cache(urtext) { super } end |