Module: RD::ComplexListItem
- Included in:
- DescListItem, MethodListItem
- Defined in:
- lib/rd2odt/rdtool/rd/complex-list-item.rb
Overview
abstruct class for ListItem which have term part additionaly. (i.e. DescListItem and MethodListItem)
Instance Method Summary collapse
- #assign_term(term) ⇒ Object
- #children ⇒ Object
- #each_block_in_description ⇒ Object (also: #each_block)
- #each_element {|_self| ... } ⇒ Object (also: #each)
- #inspect ⇒ Object
- #make_term(*args_of_new, &block) ⇒ Object
- #set_term(term) ⇒ Object (also: #term=)
- #set_term_under_document_struct(term, document_struct) ⇒ Object
- #set_term_without_document_struct(term) ⇒ Object
- #to_label ⇒ Object (also: #label)
Instance Method Details
#assign_term(term) ⇒ Object
21 22 23 24 |
# File 'lib/rd2odt/rdtool/rd/complex-list-item.rb', line 21 def assign_term(term) @term = term term.parent = self end |
#children ⇒ Object
49 50 51 |
# File 'lib/rd2odt/rdtool/rd/complex-list-item.rb', line 49 def children @description end |
#each_block_in_description ⇒ Object Also known as: each_block
42 43 44 45 46 |
# File 'lib/rd2odt/rdtool/rd/complex-list-item.rb', line 42 def each_block_in_description @description.each do |i| yield(i) end end |
#each_element {|_self| ... } ⇒ Object Also known as: each
33 34 35 36 37 38 39 |
# File 'lib/rd2odt/rdtool/rd/complex-list-item.rb', line 33 def each_element(&block) yield(self) @term.each_element(&block) @description.each do |i| i.each_element(&block) end end |
#inspect ⇒ Object
58 59 60 61 62 63 |
# File 'lib/rd2odt/rdtool/rd/complex-list-item.rb', line 58 def inspect t = indent2(term.inspect) if term c = children.collect{|i| indent2(i.inspect)}.join("\n") "<#{self.class.name}>" + (term ? "\n" : "") + t.to_s + (c.empty? ? "" : "\n") + c end |
#make_term(*args_of_new, &block) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/rd2odt/rdtool/rd/complex-list-item.rb', line 26 def make_term(*args_of_new, &block) child = self.class::Term.new(*args_of_new) set_term(child) child.build(&block) if block_given? child end |
#set_term(term) ⇒ Object Also known as: term=
7 8 9 |
# File 'lib/rd2odt/rdtool/rd/complex-list-item.rb', line 7 def set_term(term) set_term_under_document_struct(term, tree.document_struct) end |
#set_term_under_document_struct(term, document_struct) ⇒ Object
12 13 14 15 |
# File 'lib/rd2odt/rdtool/rd/complex-list-item.rb', line 12 def set_term_under_document_struct(term, document_struct) raise ArgumentError unless document_struct.is_valid?(self, term) assign_term(term) end |
#set_term_without_document_struct(term) ⇒ Object
17 18 19 |
# File 'lib/rd2odt/rdtool/rd/complex-list-item.rb', line 17 def set_term_without_document_struct(term) assign_term(term) end |
#to_label ⇒ Object Also known as: label
53 54 55 |
# File 'lib/rd2odt/rdtool/rd/complex-list-item.rb', line 53 def to_label @term.to_label end |