Class: Coradoc::Element::List::Core
- Defined in:
- lib/coradoc/element/list/core.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#anchor ⇒ Object
Returns the value of attribute anchor.
-
#id ⇒ Object
Returns the value of attribute id.
-
#items ⇒ Object
Returns the value of attribute items.
-
#ol_count ⇒ Object
Returns the value of attribute ol_count.
-
#prefix ⇒ Object
Returns the value of attribute prefix.
Instance Method Summary collapse
-
#initialize(items, options = {}) ⇒ Core
constructor
A new instance of Core.
- #to_adoc ⇒ Object
Methods inherited from Base
children_accessors, #children_accessors, declare_children, #simplify_block_content, visit, #visit
Constructor Details
#initialize(items, options = {}) ⇒ Core
Returns a new instance of Core.
12 13 14 15 16 17 18 19 |
# File 'lib/coradoc/element/list/core.rb', line 12 def initialize(items, = {}) @items = items @items = [@items] unless @items.is_a?(Array) @id = .fetch(:id, nil) @anchor = @id.nil? ? nil : Inline::Anchor.new(@id) @ol_count = .fetch(:ol_count, 1) @attrs = .fetch(:attrs, AttributeList.new) end |
Instance Attribute Details
#anchor ⇒ Object
Returns the value of attribute anchor.
8 9 10 |
# File 'lib/coradoc/element/list/core.rb', line 8 def anchor @anchor end |
#id ⇒ Object
Returns the value of attribute id.
8 9 10 |
# File 'lib/coradoc/element/list/core.rb', line 8 def id @id end |
#items ⇒ Object
Returns the value of attribute items.
8 9 10 |
# File 'lib/coradoc/element/list/core.rb', line 8 def items @items end |
#ol_count ⇒ Object
Returns the value of attribute ol_count.
8 9 10 |
# File 'lib/coradoc/element/list/core.rb', line 8 def ol_count @ol_count end |
#prefix ⇒ Object
Returns the value of attribute prefix.
8 9 10 |
# File 'lib/coradoc/element/list/core.rb', line 8 def prefix @prefix end |
Instance Method Details
#to_adoc ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/coradoc/element/list/core.rb', line 21 def to_adoc anchor = @anchor.nil? ? "" : @anchor.to_adoc.to_s attrs = @attrs.to_adoc(false).to_s content = "\n" @items.each do |item| c = Coradoc::Generator.gen_adoc(item) if !c.empty? content << prefix.to_s content << " " if c[0]!=" " content << c end end "\n#{anchor}#{attrs}" + content end |