Sha256: 20bae43b547a60d9cc81eef55875b0805dd075398459faae6d4b44bc02a659e8

Contents?: true

Size: 641 Bytes

Versions: 6

Compression:

Stored size: 641 Bytes

Contents

module RRTF
  # This class represents a list item, that can contain text or
  # other nodes. Currently any type of node is accepted, but after
  # more extensive testing this behaviour may change.
  class ListTextNode < CommandNode
    def initialize(parent, level)
      @level  = level
      @parent = parent

      number = siblings_count + 1 if parent.kind == :decimal
      prefix = "{\\listtext#{@level.marker.text_format(number)}}"
      suffix = '\\'

      super(parent, prefix, suffix, false, false)
    end

    private
      def siblings_count
        parent.children.select {|n| n.kind_of?(self.class)}.size
      end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rrtf-1.3.1 lib/rrtf/node/list_text_node.rb
rrtf-1.3.0 lib/rrtf/node/list_text_node.rb
rrtf-1.2.0 lib/rrtf/node/list_text_node.rb
rrtf-1.1.0 lib/rrtf/node/list_text_node.rb
rrtf-1.0.1 lib/rrtf/node/list_text_node.rb
rrtf-1.0.0 lib/rrtf/node/list_text_node.rb