Class: Coradoc::Element::List::Core
- Inherits:
-
Object
- Object
- Coradoc::Element::List::Core
- Defined in:
- lib/coradoc/element/list/core.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#anchor ⇒ Object
readonly
Returns the value of attribute anchor.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#ol_count ⇒ Object
readonly
Returns the value of attribute ol_count.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
Instance Method Summary collapse
-
#initialize(items, options = {}) ⇒ Core
constructor
A new instance of Core.
- #to_adoc ⇒ Object
Constructor Details
#initialize(items, options = {}) ⇒ Core
Returns a new instance of Core.
10 11 12 13 14 15 16 17 |
# File 'lib/coradoc/element/list/core.rb', line 10 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, 0) @attrs = .fetch(:attrs, nil) end |
Instance Attribute Details
#anchor ⇒ Object (readonly)
Returns the value of attribute anchor.
8 9 10 |
# File 'lib/coradoc/element/list/core.rb', line 8 def anchor @anchor end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
8 9 10 |
# File 'lib/coradoc/element/list/core.rb', line 8 def id @id end |
#items ⇒ Object (readonly)
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 (readonly)
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 (readonly)
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
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/coradoc/element/list/core.rb', line 19 def to_adoc content = "\n" @items.each do |item| c = Coradoc::Generator.gen_adoc(item) if !c.empty? content << "#{prefix}" content << c end end anchor = @anchor.nil? ? "" : "#{@anchor.to_adoc}" attrs = @attrs.nil? ? "" : "#{@attrs.to_adoc}" "\n#{anchor}#{attrs}" + content end |