Class: Coradoc::Element::ListItemDefinition
- Defined in:
- lib/coradoc/element/list_item_definition.rb
Instance Attribute Summary collapse
-
#contents ⇒ Object
Returns the value of attribute contents.
-
#id ⇒ Object
Returns the value of attribute id.
-
#terms ⇒ Object
Returns the value of attribute terms.
Instance Method Summary collapse
-
#initialize(terms, contents, options = {}) ⇒ ListItemDefinition
constructor
A new instance of ListItemDefinition.
- #to_adoc(delimiter) ⇒ Object
Methods inherited from Base
#children_accessors, children_accessors, declare_children, #simplify_block_content, visit, #visit
Constructor Details
#initialize(terms, contents, options = {}) ⇒ ListItemDefinition
Returns a new instance of ListItemDefinition.
8 9 10 11 12 13 |
# File 'lib/coradoc/element/list_item_definition.rb', line 8 def initialize(terms, contents, = {}) @terms = terms @contents = contents @id = .fetch(:id, nil) @anchor = @id.nil? ? nil : Inline::Anchor.new(@id) end |
Instance Attribute Details
#contents ⇒ Object
Returns the value of attribute contents.
4 5 6 |
# File 'lib/coradoc/element/list_item_definition.rb', line 4 def contents @contents end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/coradoc/element/list_item_definition.rb', line 4 def id @id end |
#terms ⇒ Object
Returns the value of attribute terms.
4 5 6 |
# File 'lib/coradoc/element/list_item_definition.rb', line 4 def terms @terms end |
Instance Method Details
#to_adoc(delimiter) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/coradoc/element/list_item_definition.rb', line 15 def to_adoc(delimiter) anchor = @anchor.nil? ? "" : @anchor.to_adoc.to_s content = "" if (@terms.is_a?(Array) && @terms.size == 1) || !@terms.is_a?(Array) t = Coradoc::Generator.gen_adoc(@terms) content << "#{anchor}#{t}#{delimiter} " else @terms.map do |term| t = Coradoc::Generator.gen_adoc(term) content << "#{t}#{delimiter}\n" end end d = Coradoc::Generator.gen_adoc(@contents) content << "#{d}\n" end |