Class: 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 : (Array | String)?.
-
#parts ⇒ Object
readonly
Parts of the ListItem : Array.
Instance Method Summary collapse
-
#<<(part) ⇒ Object
Appends
partto the ListItem : (untyped) -> void. -
#==(other) ⇒ Object
: (top) -> bool.
-
#accept(visitor) ⇒ Object
Runs this list item and all its #parts through
visitor: (untyped) -> void. -
#empty? ⇒ Boolean
Is the ListItem empty? : () -> bool.
-
#initialize(label = nil, *parts) ⇒ ListItem
constructor
Creates a new ListItem with an optional
labelcontainingparts: ((Array | String)?, *untyped) -> void. -
#length ⇒ Object
Length of parts in the ListItem : () -> Integer.
-
#pretty_print(q) ⇒ Object
: (PP) -> void.
-
#push(*parts) ⇒ Object
Adds
partsto the ListItem : (*untyped) -> void.
Constructor Details
Instance Attribute Details
#label ⇒ Object
The label for the ListItem : (Array | String)?
16 17 18 |
# File 'lib/rdoc/markup/list_item.rb', line 16 def label @label end |
#parts ⇒ Object (readonly)
Parts of the ListItem : Array
20 21 22 |
# File 'lib/rdoc/markup/list_item.rb', line 20 def parts @parts end |
Instance Method Details
#<<(part) ⇒ Object
Appends part to the ListItem
: (untyped) -> void
31 32 33 |
# File 'lib/rdoc/markup/list_item.rb', line 31 def <<(part) @parts << part end |
#==(other) ⇒ Object
: (top) -> bool
36 37 38 39 40 |
# File 'lib/rdoc/markup/list_item.rb', line 36 def ==(other) # :nodoc: self.class == other.class && @label == other.label && @parts == other.parts end |
#accept(visitor) ⇒ Object
Runs this list item and all its #parts through visitor
: (untyped) -> void
45 46 47 48 49 |
# File 'lib/rdoc/markup/list_item.rb', line 45 def accept(visitor) visitor.accept_list_item_start(self) @parts.each { |part| part.accept(visitor) } visitor.accept_list_item_end(self) end |
#empty? ⇒ Boolean
Is the ListItem empty? : () -> bool
53 54 55 |
# File 'lib/rdoc/markup/list_item.rb', line 53 def empty? @parts.empty? end |
#length ⇒ Object
Length of parts in the ListItem : () -> Integer
59 60 61 |
# File 'lib/rdoc/markup/list_item.rb', line 59 def length @parts.length end |
#pretty_print(q) ⇒ Object
: (PP) -> void
65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/rdoc/markup/list_item.rb', line 65 def pretty_print(q) # :nodoc: q.group(2, '[item: ', ']') do case @label when Array, String 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
: (*untyped) -> void
82 83 84 |
# File 'lib/rdoc/markup/list_item.rb', line 82 def push(*parts) @parts.concat(parts) end |