Class: RODF::Span

Inherits:
ParagraphContainer show all
Defined in:
lib/rodf/span.rb

Instance Method Summary collapse

Methods inherited from ParagraphContainer

#<<, #content_parts, #content_parts_xml, #link, #method_missing, #span, #tab

Methods inherited from Container

create

Constructor Details

#initialize(first, second = nil, style: nil, &block) ⇒ Span

Returns a new instance of Span.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rodf/span.rb', line 13

def initialize(first, second=nil, style: nil, &block)
  super(first, second, &block)

  @style = nil

  if first.instance_of?(Symbol)
    ### Legacy behaviour

    @style = first

    if !second.nil?
      content_parts << TextNode.new(second)
    end
  else
    if style
      @style = style
    end

    content_parts << TextNode.new(first)
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RODF::ParagraphContainer

Instance Method Details

#xmlObject



35
36
37
38
39
40
41
42
43
# File 'lib/rodf/span.rb', line 35

def xml
  if @style.nil?
    return content_parts_xml
  end

  Builder::XmlMarkup.new.text(:span, 'text:style-name' => @style) do |xml|
    xml << content_parts_xml
  end
end