Class: Coradoc::Element::DocumentAttributes
- Defined in:
- lib/coradoc/element/document_attributes.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
Instance Method Summary collapse
-
#initialize(data = {}, options = {}) ⇒ DocumentAttributes
constructor
A new instance of DocumentAttributes.
- #to_adoc ⇒ Object
- #to_hash ⇒ Object
Methods inherited from Base
#children_accessors, children_accessors, declare_children, #simplify_block_content, visit, #visit
Constructor Details
#initialize(data = {}, options = {}) ⇒ DocumentAttributes
Returns a new instance of DocumentAttributes.
8 9 10 11 |
# File 'lib/coradoc/element/document_attributes.rb', line 8 def initialize(data = {}, = {}) @data = data @options = end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
4 5 6 |
# File 'lib/coradoc/element/document_attributes.rb', line 4 def data @data end |
Instance Method Details
#to_adoc ⇒ Object
19 20 21 22 23 24 |
# File 'lib/coradoc/element/document_attributes.rb', line 19 def to_adoc to_hash.map do |key, value| v = value.to_s.empty? ? "" : " #{value}" ":#{key}:#{v}\n" end.join + "\n" end |
#to_hash ⇒ Object
13 14 15 16 17 |
# File 'lib/coradoc/element/document_attributes.rb', line 13 def to_hash @data.to_h do |attribute| [attribute.key.to_s, attribute.value.to_s.gsub("'", "")] end end |