Class: RDoc::Markup::ListItem
- Inherits:
-
Object
- Object
- RDoc::Markup::ListItem
- Defined in:
- lib/rdoc/markup/list_item.rb
Overview
An item within a List that contains paragraphs, headings, etc.
For BULLET, NUMBER, LALPHA and UALPHA lists, the label will always be nil. For NOTE and LABEL lists, the list label may contain:
-
a single String for a single label
-
an Array of Strings for a list item with multiple terms
-
nil for an extra description attached to a previously labeled list item
Instance Attribute Summary collapse
-
#label ⇒ Object
The label for the ListItem.
-
#parts ⇒ Object
readonly
Parts of the ListItem.
Instance Method Summary collapse
-
#<<(part) ⇒ Object
Appends
part
to the ListItem. -
#==(other) ⇒ Object
:nodoc:.
-
#accept(visitor) ⇒ Object
Runs this list item and all its #parts through
visitor
. -
#empty? ⇒ Boolean
Is the ListItem empty?.
-
#initialize(label = nil, *parts) ⇒ ListItem
constructor
Creates a new ListItem with an optional
label
containingparts
. -
#length ⇒ Object
Length of parts in the ListItem.
-
#pretty_print(q) ⇒ Object
:nodoc:.
-
#push(*parts) ⇒ Object
Adds
parts
to the ListItem.
Constructor Details
#initialize(label = nil, *parts) ⇒ ListItem
Creates a new ListItem with an optional label
containing parts
26 27 28 29 30 |
# File 'lib/rdoc/markup/list_item.rb', line 26 def initialize label = nil, *parts @label = label @parts = [] @parts.concat parts end |
Instance Attribute Details
#label ⇒ Object
The label for the ListItem
16 17 18 |
# File 'lib/rdoc/markup/list_item.rb', line 16 def label @label end |
#parts ⇒ Object (readonly)
Parts of the ListItem
21 22 23 |
# File 'lib/rdoc/markup/list_item.rb', line 21 def parts @parts end |
Instance Method Details
#<<(part) ⇒ Object
Appends part
to the ListItem
35 36 37 |
# File 'lib/rdoc/markup/list_item.rb', line 35 def << part @parts << part end |
#==(other) ⇒ Object
:nodoc:
39 40 41 42 43 |
# File 'lib/rdoc/markup/list_item.rb', line 39 def == other # :nodoc: self.class == other.class and @label == other.label and @parts == other.parts end |
#accept(visitor) ⇒ Object
Runs this list item and all its #parts through visitor
48 49 50 51 52 53 54 55 56 |
# File 'lib/rdoc/markup/list_item.rb', line 48 def accept visitor visitor.accept_list_item_start self @parts.each do |part| part.accept visitor end visitor.accept_list_item_end self end |
#empty? ⇒ Boolean
Is the ListItem empty?
61 62 63 |
# File 'lib/rdoc/markup/list_item.rb', line 61 def empty? @parts.empty? end |
#length ⇒ Object
Length of parts in the ListItem
68 69 70 |
# File 'lib/rdoc/markup/list_item.rb', line 68 def length @parts.length end |
#pretty_print(q) ⇒ Object
:nodoc:
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/rdoc/markup/list_item.rb', line 72 def pretty_print q # :nodoc: q.group 2, '[item: ', ']' do case @label when Array then q.pp @label q.text ';' q.breakable when String then q.pp @label q.text ';' q.breakable end q.seplist @parts do |part| q.pp part end end end |
#push(*parts) ⇒ Object
Adds parts
to the ListItem
94 95 96 |
# File 'lib/rdoc/markup/list_item.rb', line 94 def push *parts @parts.concat parts end |