Class: Docxtor::RunningElement
- Inherits:
-
Object
- Object
- Docxtor::RunningElement
- Defined in:
- lib/docxtor/running_element.rb
Instance Attribute Summary collapse
-
#pages ⇒ Object
Returns the value of attribute pages.
-
#reference_id ⇒ Object
Returns the value of attribute reference_id.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #content ⇒ Object
- #filename ⇒ Object
-
#initialize(type, num, contents, options = {}) ⇒ RunningElement
constructor
A new instance of RunningElement.
- #name ⇒ Object
- #reference_name ⇒ Object
- #reference_type ⇒ Object
Constructor Details
#initialize(type, num, contents, options = {}) ⇒ RunningElement
Returns a new instance of RunningElement.
5 6 7 8 9 10 11 |
# File 'lib/docxtor/running_element.rb', line 5 def initialize type, num, contents, = {} @type = type @contents = contents @align = [:align] @pages = [:pages] || :default @num = num end |
Instance Attribute Details
#pages ⇒ Object
Returns the value of attribute pages.
3 4 5 |
# File 'lib/docxtor/running_element.rb', line 3 def pages @pages end |
#reference_id ⇒ Object
Returns the value of attribute reference_id.
3 4 5 |
# File 'lib/docxtor/running_element.rb', line 3 def reference_id @reference_id end |
#type ⇒ Object
Returns the value of attribute type.
3 4 5 |
# File 'lib/docxtor/running_element.rb', line 3 def type @type end |
Instance Method Details
#content ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/docxtor/running_element.rb', line 29 def content xml = ::Builder::XmlMarkup.new xml.instruct! :xml, :version => "1.0", :encoding=>"UTF-8", :standalone => "yes" xml.w :ftr, "xmlns:o" => "urn:schemas-microsoft-com:office:office", "xmlns:r" => "http://schemas.openxmlformats.org/officeDocument/2006/relationships", "xmlns:v" => "urn:schemas-microsoft-com:vml", "xmlns:w" => "http://schemas.openxmlformats.org/wordprocessingml/2006/main", "xmlns:w10" => "urn:schemas-microsoft-com:office:word", "xmlns:wp" => "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" do |xml| xml.w :p do |xml| xml.w :pPr do |xml| xml.w :jc, "w:val" => "#{@align}" if @align end if @contents == :pagenum xml.w :r do |xml| xml.w :fldChar, "w:fldCharType" => "begin" end xml.w :r do |xml| xml.w :instrText, "PAGE" end xml.w :r do |xml| xml.w :fldChar, "w:fldCharType" => "separate" end xml.w :r do |xml| xml.w :t, "i" end xml.w :r do |xml| xml.w :fldChar, "w:fldCharType" => "end" end else xml.w :r do |xml| xml.w :t, @contents end end end end end |
#filename ⇒ Object
21 22 23 |
# File 'lib/docxtor/running_element.rb', line 21 def filename "word/#{name}" end |
#name ⇒ Object
17 18 19 |
# File 'lib/docxtor/running_element.rb', line 17 def name "#{type}#{@num}.xml" end |
#reference_name ⇒ Object
13 14 15 |
# File 'lib/docxtor/running_element.rb', line 13 def reference_name "#{type}Reference" end |
#reference_type ⇒ Object
25 26 27 |
# File 'lib/docxtor/running_element.rb', line 25 def reference_type "http://schemas.openxmlformats.org/officeDocument/2006/relationships/#{type}" end |