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
partto 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
labelcontainingparts. - 
  
    
      #length  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Length of parts in the ListItem.
 - 
  
    
      #pretty_print(q)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
:nodoc:.
 - 
  
    
      #push(*parts)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Adds
partsto the ListItem. 
Constructor Details
#initialize(label = nil, *parts) ⇒ ListItem
Creates a new ListItem with an optional label containing parts
      27 28 29 30 31  | 
    
      # File 'lib/rdoc/markup/list_item.rb', line 27 def initialize label = nil, *parts @label = label @parts = [] @parts.concat parts end  | 
  
Instance Attribute Details
#label ⇒ Object
The label for the ListItem
      17 18 19  | 
    
      # File 'lib/rdoc/markup/list_item.rb', line 17 def label @label end  | 
  
#parts ⇒ Object (readonly)
Parts of the ListItem
      22 23 24  | 
    
      # File 'lib/rdoc/markup/list_item.rb', line 22 def parts @parts end  | 
  
Instance Method Details
#<<(part) ⇒ Object
Appends part to the ListItem
      36 37 38  | 
    
      # File 'lib/rdoc/markup/list_item.rb', line 36 def << part @parts << part end  | 
  
#==(other) ⇒ Object
:nodoc:
      40 41 42 43 44  | 
    
      # File 'lib/rdoc/markup/list_item.rb', line 40 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
      49 50 51 52 53 54 55 56 57  | 
    
      # File 'lib/rdoc/markup/list_item.rb', line 49 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?
      62 63 64  | 
    
      # File 'lib/rdoc/markup/list_item.rb', line 62 def empty? @parts.empty? end  | 
  
#length ⇒ Object
Length of parts in the ListItem
      69 70 71  | 
    
      # File 'lib/rdoc/markup/list_item.rb', line 69 def length @parts.length end  | 
  
#pretty_print(q) ⇒ Object
:nodoc:
      73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90  | 
    
      # File 'lib/rdoc/markup/list_item.rb', line 73 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
      95 96 97  | 
    
      # File 'lib/rdoc/markup/list_item.rb', line 95 def push *parts @parts.concat parts end  |