Class: RubyBBCode::TagNode
- Inherits:
-
Object
- Object
- RubyBBCode::TagNode
- Defined in:
- lib/ruby-bbcode/tag_node.rb
Overview
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
Instance Attribute Summary collapse
-
#element ⇒ Object
Tag or text element that is stored in this node.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
-
#allow_params? ⇒ Boolean
Returns true if the tag is allowed to have parameters.
-
#children ⇒ Object
Return an list containing the child nodes of this node.
-
#definition ⇒ Object
shows the tag definition for this TagNode as defined in tags.rb.
-
#has_children? ⇒ Boolean
Returns true id the node that child nodes.
-
#initialize(element, nodes = []) ⇒ TagNode
constructor
Attributes.
-
#invalid_quick_param? ⇒ Boolean
Returns true when the quick parameter was invalid (i.e. it did not match the required format).
-
#params_not_set? ⇒ Boolean
Returns true if the tag does not have any parameters set.
-
#type ⇒ Object
Returns :tag is the node is a tag node, and :text if the node is a text node.
Constructor Details
#initialize(element, nodes = []) ⇒ TagNode
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
18 19 20 |
# File 'lib/ruby-bbcode/tag_node.rb', line 18 def initialize(element, nodes = []) @element = element end |
Instance Attribute Details
#element ⇒ Object
Tag or text element that is stored in this node
8 9 10 |
# File 'lib/ruby-bbcode/tag_node.rb', line 8 def element @element end |
Instance Method Details
#[](key) ⇒ Object
22 23 24 |
# File 'lib/ruby-bbcode/tag_node.rb', line 22 def [](key) @element[key] end |
#[]=(key, value) ⇒ Object
26 27 28 |
# File 'lib/ruby-bbcode/tag_node.rb', line 26 def []=(key, value) @element[key] = value end |
#allow_params? ⇒ Boolean
Returns true if the tag is allowed to have parameters
36 37 38 |
# File 'lib/ruby-bbcode/tag_node.rb', line 36 def allow_params? definition[:param_tokens] end |
#children ⇒ Object
Return an list containing the child nodes of this node.
61 62 63 |
# File 'lib/ruby-bbcode/tag_node.rb', line 61 def children @element[:nodes] end |
#definition ⇒ Object
shows the tag definition for this TagNode as defined in tags.rb
56 57 58 |
# File 'lib/ruby-bbcode/tag_node.rb', line 56 def definition @element[:definition] end |
#has_children? ⇒ Boolean
Returns true id the node that child nodes
46 47 48 |
# File 'lib/ruby-bbcode/tag_node.rb', line 46 def has_children? type == :tag and children.length > 0 end |
#invalid_quick_param? ⇒ Boolean
Returns true when the quick parameter was invalid (i.e. it did not match the required format)
51 52 53 |
# File 'lib/ruby-bbcode/tag_node.rb', line 51 def invalid_quick_param? @element.key? :invalid_quick_param end |
#params_not_set? ⇒ Boolean
Returns true if the tag does not have any parameters set.
41 42 43 |
# File 'lib/ruby-bbcode/tag_node.rb', line 41 def params_not_set? @element[:params].length == 0 end |
#type ⇒ Object
Returns :tag is the node is a tag node, and :text if the node is a text node
31 32 33 |
# File 'lib/ruby-bbcode/tag_node.rb', line 31 def type @element[:is_tag] ? :tag : :text end |