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

element[RW]

Tag or text element that is stored in this node

Public Class Methods

new(element) click to toggle source

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

[](key) click to toggle source
# File lib/ruby-bbcode/tag_node.rb, line 22
def [](key)
  @element[key]
end
[]=(key, value) click to toggle source
# File lib/ruby-bbcode/tag_node.rb, line 26
def []=(key, value)
  @element[key] = value
end
allow_params?() click to toggle source

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
children() click to toggle source

Return an list containing the child nodes of this node.

# File lib/ruby-bbcode/tag_node.rb, line 61
def children
  @element[:nodes]
end
definition() click to toggle source

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
has_children?() click to toggle source

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
invalid_quick_param?() click to toggle source

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
params_not_set?() click to toggle source

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
type() click to toggle source

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