Class: Coradoc::Element::Inline::Span
- Defined in:
- lib/coradoc/element/inline/span.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#role ⇒ Object
Returns the value of attribute role.
-
#text ⇒ Object
Returns the value of attribute text.
-
#unconstrained ⇒ Object
Returns the value of attribute unconstrained.
Instance Method Summary collapse
-
#initialize(text, options = {}) ⇒ Span
constructor
A new instance of Span.
- #to_adoc ⇒ Object
Methods inherited from Base
access_children, #children_accessors, children_accessors, declare_children, #simplify_block_content, visit, #visit
Constructor Details
#initialize(text, options = {}) ⇒ Span
Returns a new instance of Span.
9 10 11 12 13 14 |
# File 'lib/coradoc/element/inline/span.rb', line 9 def initialize(text, = {}) @text = text @role = .fetch(:role, nil) @attributes = .fetch(:attributes, nil) @unconstrained = .fetch(:unconstrained, false) end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
5 6 7 |
# File 'lib/coradoc/element/inline/span.rb', line 5 def attributes @attributes end |
#role ⇒ Object
Returns the value of attribute role.
5 6 7 |
# File 'lib/coradoc/element/inline/span.rb', line 5 def role @role end |
#text ⇒ Object
Returns the value of attribute text.
5 6 7 |
# File 'lib/coradoc/element/inline/span.rb', line 5 def text @text end |
#unconstrained ⇒ Object
Returns the value of attribute unconstrained.
5 6 7 |
# File 'lib/coradoc/element/inline/span.rb', line 5 def unconstrained @unconstrained end |
Instance Method Details
#to_adoc ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/coradoc/element/inline/span.rb', line 16 def to_adoc if @attributes attr_string = @attributes.to_adoc if @unconstrained "#{attr_string}###{@text}##" else "#{attr_string}##{@text}#" end elsif @role if @unconstrained "[.#{@role}]###{@text}##" else "[.#{@role}]##{@text}#" end else @text.to_s end end |