Class: SistemKebut::Paragraph::XMLBuilder
- Inherits:
-
SistemKebut::PembangunXML
- Object
- SistemKebut::PembangunXML
- SistemKebut::Paragraph::XMLBuilder
- Defined in:
- lib/kompleks/text.rb,
lib/kompleks/chunk.rb,
lib/kompleks/dasar.rb,
lib/kompleks/formulir.rb,
lib/kompleks/paragraph.rb,
lib/kompleks/penomoran.rb,
lib/kompleks/meja_sekat.rb
Instance Method Summary collapse
- #bold ⇒ Object
- #build_konten(*args) ⇒ Object
- #build_meja_sekat ⇒ Object
- #build_paragraph(*args) ⇒ Object
- #build_penomoran(teks) ⇒ Object
- #font_style ⇒ Object
- #formulir ⇒ Object
- #italic ⇒ Object
- #kindent ⇒ Object
- #spacing ⇒ Object
- #start ⇒ Object
- #underline ⇒ Object
Instance Method Details
#bold ⇒ Object
21 22 23 24 |
# File 'lib/kompleks/chunk.rb', line 21 def bold xml.b xml.bCs end |
#build_konten(*args) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/kompleks/text.rb', line 4 def build_konten(*args) case sumber when MejaSekatPantulan xml.t(args.first) when SistemKebut::Paragraph::Formulir unit = args.shift expectacy = SistemKebut::Paragraph::Formulir::UnitFormulir return nil unless unit.kind_of?(expectacy) if unit.label.empty? xml.tab else xml.t(unit.label) xml.tab xml.t(':') end xml.tab xml.t(unit.value) when SistemKebut::Paragraph::Penomoran xml.t(args.shift) else xml.t(sumber.konten) end end |
#build_meja_sekat ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/kompleks/meja_sekat.rb', line 4 def build_meja_sekat xml.tbl do xml.tblPr do xml.tblW('w:w' => '5000', 'w:type' => 'pct') xml.jc('w:val' => 'left') xml.tblInd('w:w' => '0', 'w:type' => 'dxa') xml.tblLayout('w:type' => 'fixed') xml.tblCellMar do xml.top('w:w' => '0', 'w:type' => 'dxa') xml.start('w:w' => '0', 'w:type' => 'dxa') xml.bottom('w:w' => '0', 'w:type' => 'dxa') xml.end('w:w' => '0', 'w:type' => 'dxa') end end xml.tblGrid do xml.gridCol('w:w' => '4818') xml.gridCol('w:w' => '4819') end xml.tr do xml.trPr urutan = 0 kepala = sumber.kepala if kepala.nil? unit = [nil] * sumber.jumlah kepala = SistemKebut::Paragraph::MejaSekat::Unit.new(sumber.jumlah, *unit) end kepala.tiap do |label| xml.tc do xml.tcPr do xml.tcW('w:w' => (4818 + urutan).to_s, 'w:type' => 'dxa') xml.tcBorders end xml.p do xml.pPr do xml.pStyle('w:val' => 'Normal') xml.bidi('w:val' => '0') xml.jc('w:val' => 'center') xml.rPr do font_style end end xml.r do xml.rPr do font_style bold end xml.t(label.nil? ? '' : label) end end end urutan += 1 end end sumber.tiap do |unit| xml.tr do xml.trPr urutan = 0 unit.tiap do |label| xml.tc do xml.tcPr do xml.tcW('w:w' => (4818 + urutan).to_s, 'w:type' => 'dxa') xml.tcBorders end lama = sumber pantulan = MejaSekatPantulan.new(unit, sumber) build(pantulan).build_paragraph(label) build(lama) end urutan += 1 end end end end end |
#build_paragraph(*args) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/kompleks/paragraph.rb', line 4 def build_paragraph(*args) xml.p do xml.pPr do xml.pStyle('w:val' => 'Normal') xml.bidi('w:val' => '0') if sumber.mode == :pustaka xml.ind('w:left' => '720', 'w:firstLine' => '-720') else case sumber when SistemKebut::Paragraph::Kutipan kindent when SistemKebut::Paragraph::Formulir formulir end end spacing xml.jc('w:val' => sumber.align.to_s) xml.rPr do font_style end end xml.r do xml.rPr do font_style bold if sumber.bold italic if sumber.italic underline if sumber.underline xml.sz('w:val' => sumber.fsize.to_s) xml.szCs('w:val' => sumber.fsize.to_s) end xml.tab if sumber.masuk build_konten(*args) end end end |
#build_penomoran(teks) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 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 49 50 51 52 |
# File 'lib/kompleks/penomoran.rb', line 4 def build_penomoran(teks) permulaan = false if @_permulaan_penomoran.nil? if Gudang::NUMBERING_PERLENGKAPAN[:jumlah] > 1 permulaan = true end @_permulaan_penomoran = sumber.numid Gudang::NUMBERING_PERLENGKAPAN[:jumlah] += 1 elsif @_permulaan_penomoran != sumber.numid permulaan = true @_permulaan_penomoran = sumber.numid Gudang::NUMBERING_PERLENGKAPAN[:jumlah] += 1 end xml.p do xml.pPr do xml.pStyle('w:val' => 'Normal') xml.bidi('w:val' => '0') if permulaan xml.numPr do xml.ilvl('w:val' => '0') xml.numId('w:val' => sumber.numid.to_s) end else xml.numPr do xml.ilvl('w:val' => '0') xml.numId('w:val' => '1') end end xml.jc('w:val' => sumber.align.to_s) xml.rPr do font_style xml.sz('w:val' => sumber.fsize.to_s) xml.szCs('w:val' => sumber.fsize.to_s) end end xml.r do xml.rPr do font_style bold if sumber.bold italic if sumber.italic underline if sumber.underline xml.sz('w:val' => sumber.fsize.to_s) xml.szCs('w:val' => sumber.fsize.to_s) end xml.tab if sumber.masuk build_konten(teks) end end end |
#font_style ⇒ Object
4 5 6 |
# File 'lib/kompleks/chunk.rb', line 4 def font_style xml.rFonts('w:ascii' => sumber.fstyle, 'w:hAnsi' => sumber.fstyle) end |
#formulir ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'lib/kompleks/formulir.rb', line 4 def formulir knt = (sumber.tabsize + 720).to_s tab = sumber.tabsize.to_s xml.ind('w:left' => knt, 'w:firstLine' => '-'.concat(knt)) xml.tabs do xml.tab('w:val' => 'left', 'w:pos' => tab) xml.tab('w:val' => 'left', 'w:pos' => knt) end end |
#italic ⇒ Object
26 27 28 29 |
# File 'lib/kompleks/chunk.rb', line 26 def italic xml.i xml.iCs end |
#kindent ⇒ Object
17 18 19 |
# File 'lib/kompleks/chunk.rb', line 17 def kindent xml.ind('w:left' => '1440', 'w:right' => '1440') end |
#spacing ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/kompleks/chunk.rb', line 8 def spacing case sumber.spacing when :kecil xml.spacing('w:before' => '0', 'w:after' => '0', 'w:line' => '240', 'w:lineRule' => 'auto') when :ganda xml.spacing('w:before' => '0', 'w:after' => '0', 'w:line' => '480', 'w:lineRule' => 'auto') end end |
#start ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/kompleks/dasar.rb', line 23 def start xml.produk do case sumber when SistemKebut::Paragraph::MejaSekat build_meja_sekat when SistemKebut::Paragraph::Formulir sumber.tiap(&method(:build_paragraph)) when SistemKebut::Paragraph::Penomoran sumber.tiap(&method(:build_penomoran)) else build_paragraph end end end |
#underline ⇒ Object
31 32 33 |
# File 'lib/kompleks/chunk.rb', line 31 def underline xml.u('w:val' => 'single') end |