Class: Markbridge::Parsers::TextFormatter::Handlers::AttributeHandler
- Inherits:
-
BaseHandler
- Object
- BaseHandler
- Markbridge::Parsers::TextFormatter::Handlers::AttributeHandler
- Defined in:
- lib/markbridge/parsers/text_formatter/handlers/attribute_handler.rb
Overview
Generic handler for elements that take a single attribute
This handler extracts a specified attribute and passes it to the AST node constructor. Use this for elements like COLOR, SIZE, ALIGN, SPOILER.
Instance Attribute Summary collapse
-
#element_class ⇒ Object
readonly
Returns the value of attribute element_class.
Instance Method Summary collapse
-
#initialize(element_class, attribute:, param: nil) ⇒ AttributeHandler
constructor
A new instance of AttributeHandler.
- #process(element:, parent:) ⇒ Object
Constructor Details
#initialize(element_class, attribute:, param: nil) ⇒ AttributeHandler
Returns a new instance of AttributeHandler.
20 21 22 23 24 |
# File 'lib/markbridge/parsers/text_formatter/handlers/attribute_handler.rb', line 20 def initialize(element_class, attribute:, param: nil) @element_class = element_class @attribute = attribute @param = param || attribute end |
Instance Attribute Details
#element_class ⇒ Object (readonly)
Returns the value of attribute element_class.
35 36 37 |
# File 'lib/markbridge/parsers/text_formatter/handlers/attribute_handler.rb', line 35 def element_class @element_class end |
Instance Method Details
#process(element:, parent:) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/markbridge/parsers/text_formatter/handlers/attribute_handler.rb', line 26 def process(element:, parent:) attrs = extract_attributes(element) node = @element_class.new(@param => attrs[@attribute]) parent << node # Return node to signal: process children into this node node end |