Class: Bbcode::Base
- Inherits:
-
Object
- Object
- Bbcode::Base
- Defined in:
- lib/bbcode/base.rb
Constant Summary collapse
- @@handlers =
HashWithIndifferentAccess.new
Instance Attribute Summary collapse
-
#locals ⇒ Object
readonly
Returns the value of attribute locals.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(parser, string) ⇒ Base
constructor
A new instance of Base.
- #to(handler_name, locals = {}) ⇒ Object
Constructor Details
#initialize(parser, string) ⇒ Base
Returns a new instance of Base.
7 8 9 10 |
# File 'lib/bbcode/base.rb', line 7 def initialize(parser, string) @parser = parser @string = string end |
Instance Attribute Details
#locals ⇒ Object (readonly)
Returns the value of attribute locals.
5 6 7 |
# File 'lib/bbcode/base.rb', line 5 def locals @locals end |
Class Method Details
.register_handler(name, handler) ⇒ Object
22 23 24 25 |
# File 'lib/bbcode/base.rb', line 22 def self.register_handler(name, handler) puts "WARNING: Bbcode::Base.register_handler is deprecated. Use Bbcode.register_handler instead." Bbcode.register_handler(name, handler) end |
Instance Method Details
#to(handler_name, locals = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/bbcode/base.rb', line 12 def to(handler_name, locals = {}) handler = Bbcode.handler handler_name raise "Handler #{handler} isn't registered." if handler.nil? handler.locals = locals.with_indifferent_access @parser.parse @string, handler result = handler.get_document.content.to_s handler.clear result end |