Class: PPtxt::PPtxtSlide
- Inherits:
-
Object
- Object
- PPtxt::PPtxtSlide
- Defined in:
- lib/pptxt/slide.rb
Instance Method Summary collapse
- #detailed ⇒ Object
- #diffable ⇒ Object
-
#initialize(xml, count) ⇒ PPtxtSlide
constructor
A new instance of PPtxtSlide.
- #to_s ⇒ Object
Constructor Details
#initialize(xml, count) ⇒ PPtxtSlide
Returns a new instance of PPtxtSlide.
55 56 57 58 59 60 61 62 |
# File 'lib/pptxt/slide.rb', line 55 def initialize(xml, count) @content = "" @count = count @subtitle = "" @title = "" @xml = xml parse_xml end |
Instance Method Details
#detailed ⇒ Object
2 3 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 |
# File 'lib/pptxt/slide.rb', line 2 def detailed ret = Array.new num_indents = 0 @xml.each_line do |line| line.strip! indents = Array.new(num_indents, " ").join case line when %r{^<\?.+$}, "" # Ignore xml version and blank lines when %r{^<.+/> *$}, %r{^<[^/].+>.*</.+> *$} # Don't indent if one-liner ret.push("#{indents}#{line}") when %r{^<[^/].+$} # Indent after opening tag ret.push("#{indents}#{line}") num_indents += 1 when %r{^</.+> *$} # Remove indent after closing tag num_indents -= 1 indents = Array.new(num_indents, " ").join ret.push("#{indents}#{line}") else raise PPtxt::Error::UnknownXML.new(line) end end return ret.join("\n") end |
#diffable ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/pptxt/slide.rb', line 33 def diffable out = Array.new out.push(@title) if (!@title.empty?) out.push(@subtitle) if (!@subtitle.empty?) out.push("\n") if (!@title.empty? || !@subtitle.empty?) out.push(@content) if (!@content.empty?) return out.join.strip end |
#to_s ⇒ Object
171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/pptxt/slide.rb', line 171 def to_s() div = Array.new(70, "-").join out = Array.new out.push("#{div}\n") out.push(@title) if (!@title.empty?) out.push(@subtitle) if (!@subtitle.empty?) out.push("\n") if (!@title.empty? || !@subtitle.empty?) out.push(@content) if (!@content.empty?) out.push("#{div} #{@count}\n") return out.join.strip end |