Module: RD::ComplexListItem

Included in:
DescListItem, MethodListItem
Defined in:
lib/rd/complex-list-item.rb

Overview

abstruct class for ListItem which have term part additionaly. (i.e. DescListItem and MethodListItem)

Instance Method Summary collapse

Instance Method Details

#assign_term(term) ⇒ Object



21
22
23
24
# File 'lib/rd/complex-list-item.rb', line 21

def assign_term(term)
  @term = term
  term.parent = self
end

#childrenObject



49
50
51
# File 'lib/rd/complex-list-item.rb', line 49

def children
  @description
end

#each_block_in_descriptionObject Also known as: each_block



42
43
44
45
46
# File 'lib/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

Yields:

  • (_self)

Yield Parameters:



33
34
35
36
37
38
39
# File 'lib/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

#inspectObject



58
59
60
61
62
63
# File 'lib/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/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/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

Raises:

  • (ArgumentError)


12
13
14
15
# File 'lib/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/rd/complex-list-item.rb', line 17

def set_term_without_document_struct(term)
  assign_term(term)
end

#to_labelObject Also known as: label



53
54
55
# File 'lib/rd/complex-list-item.rb', line 53

def to_label
  @term.to_label
end