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
access_children, #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 = 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 25 26 27 28 29 30 |
# File 'lib/coradoc/element/document_attributes.rb', line 19 def to_adoc to_hash.map do |key, value| v = if value.to_s.empty? "" elsif value.is_a? Array " #{value.join(',')}" else " #{value}" end ":#{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, attribute.value] end end |