class RubyBBCode::TagNode
A TagNode
specifies either an opening tag element or a (plain) text elements
TagInfo
elements are essentially converted into these nodes which are later converted into html output in the bbtree_to_html method
Attributes
Tag or text element that is stored in this node
Public Class Methods
Attributes¶ ↑
-
element
- contains the information of TagInfo#tag_data. A text element has the form of{ :is_tag=>false, :text=>"ITALIC" }
and a tag element has the form of
{ :is_tag=>true, :tag=>:i, :nodes => [] }
-
nodes
# File lib/ruby-bbcode/tag_node.rb, line 18 def initialize(element) @element = element end
Public Instance Methods
# File lib/ruby-bbcode/tag_node.rb, line 22 def [](key) @element[key] end
# File lib/ruby-bbcode/tag_node.rb, line 26 def []=(key, value) @element[key] = value end
Returns true if the tag is allowed to have parameters
# File lib/ruby-bbcode/tag_node.rb, line 36 def allow_params? definition[:param_tokens] end
Return an list containing the child nodes of this node.
# File lib/ruby-bbcode/tag_node.rb, line 61 def children @element[:nodes] end
shows the tag definition for this TagNode
as defined in tags.rb
# File lib/ruby-bbcode/tag_node.rb, line 56 def definition @element[:definition] end
Returns true if the node that child nodes
# File lib/ruby-bbcode/tag_node.rb, line 46 def has_children? (type == :tag) && !children.empty? end
Returns true when the quick parameter was invalid (i.e. it did not match the required format)
# File lib/ruby-bbcode/tag_node.rb, line 51 def invalid_quick_param? @element.key? :invalid_quick_param end
Returns true if the tag does not have any parameters set.
# File lib/ruby-bbcode/tag_node.rb, line 41 def params_not_set? @element[:params].empty? end
Returns :tag is the node is a tag node, and :text if the node is a text node
# File lib/ruby-bbcode/tag_node.rb, line 31 def type @element[:is_tag] ? :tag : :text end