Class: RubyBBCode::TagNode
- Inherits:
-
Object
- Object
- RubyBBCode::TagNode
- Includes:
- DebugBBTree
- Defined in:
- lib/ruby-bbcode-to-md/tag_node.rb
Overview
TagNodes are nodes that are stored up in the BBTree’s @current_node.children array I think… which is a bit misleading…
TagNodes specify either opening tag elements or 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
Returns the value of attribute element.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #allow_tag_param? ⇒ Boolean
- #children ⇒ Object
-
#definition ⇒ Object
shows the tag definition for this TagNode as defined in tags.rb.
- #has_children? ⇒ Boolean
-
#initialize(element, nodes = []) ⇒ TagNode
constructor
A new instance of TagNode.
-
#param_not_set? ⇒ Boolean
Checks to see if the parameter for the TagNode has been set.
-
#param_set? ⇒ Boolean
check if the parameter for the TagNode is set.
- #parent_type ⇒ Object
-
#tag_param=(param) ⇒ Object
Easy way to set the tag_param value of the hash, which represents the parameter supplied.
-
#type ⇒ Object
Debugging/ visualization purposes.
Methods included from DebugBBTree
#count_child_nodes, #to_s, #to_v
Constructor Details
#initialize(element, nodes = []) ⇒ TagNode
Returns a new instance of TagNode.
10 11 12 |
# File 'lib/ruby-bbcode-to-md/tag_node.rb', line 10 def initialize(element, nodes = []) @element = element # { :is_tag=>false, :text=>"ITALLICS" } || { :is_tag=>true, :tag=>:i, :nodes => [] } end |
Instance Attribute Details
#element ⇒ Object
Returns the value of attribute element.
8 9 10 |
# File 'lib/ruby-bbcode-to-md/tag_node.rb', line 8 def element @element end |
Instance Method Details
#[](key) ⇒ Object
14 15 16 |
# File 'lib/ruby-bbcode-to-md/tag_node.rb', line 14 def [](key) @element[key] end |
#[]=(key, value) ⇒ Object
18 19 20 |
# File 'lib/ruby-bbcode-to-md/tag_node.rb', line 18 def []=(key, value) @element[key] = value end |
#allow_tag_param? ⇒ Boolean
47 48 49 |
# File 'lib/ruby-bbcode-to-md/tag_node.rb', line 47 def allow_tag_param? definition[:allow_tag_param] end |
#children ⇒ Object
56 57 58 |
# File 'lib/ruby-bbcode-to-md/tag_node.rb', line 56 def children @element[:nodes] end |
#definition ⇒ Object
shows the tag definition for this TagNode as defined in tags.rb
52 53 54 |
# File 'lib/ruby-bbcode-to-md/tag_node.rb', line 52 def definition @element[:definition] end |
#has_children? ⇒ Boolean
42 43 44 45 |
# File 'lib/ruby-bbcode-to-md/tag_node.rb', line 42 def has_children? return false if type == :text or children.length == 0 # text nodes return false too return true if children.length > 0 end |
#param_not_set? ⇒ Boolean
Checks to see if the parameter for the TagNode has been set.
33 34 35 |
# File 'lib/ruby-bbcode-to-md/tag_node.rb', line 33 def param_not_set? (@element[:params].nil? or @element[:params][:tag_param].nil?) end |
#param_set? ⇒ Boolean
check if the parameter for the TagNode is set
38 39 40 |
# File 'lib/ruby-bbcode-to-md/tag_node.rb', line 38 def param_set? !param_not_set? end |
#parent_type ⇒ Object
28 29 30 |
# File 'lib/ruby-bbcode-to-md/tag_node.rb', line 28 def parent_type @element[:parent_tag] end |
#tag_param=(param) ⇒ Object
Easy way to set the tag_param value of the hash, which represents the parameter supplied
62 63 64 |
# File 'lib/ruby-bbcode-to-md/tag_node.rb', line 62 def tag_param=(param) @element[:params] = {:tag_param => param} end |
#type ⇒ Object
Debugging/ visualization purposes
23 24 25 26 |
# File 'lib/ruby-bbcode-to-md/tag_node.rb', line 23 def type return :tag if @element[:is_tag] return :text if !@element[:is_tag] end |