Class: Docxi::Word::Contents::Frame

Inherits:
Object
  • Object
show all
Defined in:
lib/docxi/word/contents/frame.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Frame

Returns a new instance of Frame.



8
9
10
11
12
13
14
15
16
# File 'lib/docxi/word/contents/frame.rb', line 8

def initialize(options={})
  @content = []
  @options = options
  if block_given?
    yield self
  else

  end
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



7
8
9
# File 'lib/docxi/word/contents/frame.rb', line 7

def content
  @content
end

#optionsObject

Returns the value of attribute options.



7
8
9
# File 'lib/docxi/word/contents/frame.rb', line 7

def options
  @options
end

Instance Method Details

#br(options = {}) ⇒ Object



50
51
52
53
54
# File 'lib/docxi/word/contents/frame.rb', line 50

def br(options={})
  br = Docxi::Word::Contents::Break.new(options)
  @content << br
  br
end

#frame(options = {}, &block) ⇒ Object



62
63
64
65
66
# File 'lib/docxi/word/contents/frame.rb', line 62

def frame(options={}, &block)
  element = Docxi::Word::Contents::Frame.new(options, &block)
  @content << element
  element
end

#image(image, options = {}) ⇒ Object



75
76
77
78
79
# File 'lib/docxi/word/contents/frame.rb', line 75

def image(image, options={})
  img = Docxi::Word::Contents::Image.new(image, options)
  @content << img
  img
end

#render(xml) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/docxi/word/contents/frame.rb', line 18

def render(xml)
  xml['w'].r do
    xml['w'].pict do
      xml['v'].rect("fillcolor"=>"#bfbfbf[2412]", "strokecolor"=>"000000","strokeweight"=>"0pt", "style"=> @options[:style]) do
        xml['v'].fill("opacity" =>"52429f")
        xml['v'].textbox("inset" => "0in,0in,0in,0in") do 
          xml['w'].txbxContent do
            xml['w'].p do
              xml['w'].pPr do
              xml['w'].pStyle('w:val'=>"Normal")
                xml['w'].pBdr do
                  xml['w'].top('w:val'=>"nil")
                  xml['w'].left('w:val'=>"nil")
                  xml['w'].bottom('w:val'=>"nil")
                  xml['w'].right('w:val'=>"nil")
                end
                if @options[:spacing]
                  xml['w'].spacing('w:before'=>"240")
                end
              end
              @content.each do |element|
                element.render(xml)
              end
            end
          end
        end
      xml['w10'].wrap('type'=>"topAndBottom")
      end
    end
  end
end

#tab(options = {}) ⇒ Object



56
57
58
59
60
# File 'lib/docxi/word/contents/frame.rb', line 56

def tab(options={})
  tab = Docxi::Word::Contents::Tab.new(options)
  @content << tab
  tab
end

#text(text, options = {}) ⇒ Object



68
69
70
71
72
73
# File 'lib/docxi/word/contents/frame.rb', line 68

def text(text, options={})
  options = @options.merge(options)
  text = Docxi::Word::Contents::Text.new(text, options)
  @content << text
  text
end