Class: Rabbit::HTML::Generator
- Inherits:
-
Object
- Object
- Rabbit::HTML::Generator
- Includes:
- ERB::Util, GetText
- Defined in:
- lib/rabbit/html/generator.rb
Constant Summary
Constants included from GetText
Instance Attribute Summary collapse
-
#pdf_filename ⇒ Object
Returns the value of attribute pdf_filename.
-
#source_filename ⇒ Object
Returns the value of attribute source_filename.
Instance Method Summary collapse
- #index_href(slide_number) ⇒ Object
- #index_image_title(slide_number) ⇒ Object
-
#initialize(canvas, base_name, image_type, output_html, output_index_html, rss_base_uri) ⇒ Generator
constructor
A new instance of Generator.
- #number_of_places(num) ⇒ Object
- #output_html? ⇒ Boolean
- #output_index_html? ⇒ Boolean
- #output_slide_html? ⇒ Boolean
- #outputting_index? ⇒ Boolean
- #save ⇒ Object
- #save_pixbuf(pixbuf, optional = nil) ⇒ Object
- #slide_href(slide_number) ⇒ Object
- #slide_image_title(slide_number) ⇒ Object
- #with_outputting_index(index) ⇒ Object
Methods included from GetText
Constructor Details
#initialize(canvas, base_name, image_type, output_html, output_index_html, rss_base_uri) ⇒ Generator
Returns a new instance of Generator.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/rabbit/html/generator.rb', line 52 def initialize(canvas, base_name, image_type, output_html, output_index_html, rss_base_uri) @canvas = canvas @suffix = "html" @rss_info = [] @rss_filename = "index.rdf" rss_base_uri = rss_base_uri.chomp('/') + '/' if rss_base_uri @rss_base_uri = rss_base_uri @base_name = base_name @base_dir = File.dirname(@base_name) @image_type = image_type @output_html = output_html @output_index_html = output_index_html @pdf_filename = nil @source_filename = nil FileUtils.mkdir_p(Filename.new(@base_dir).encode) end |
Instance Attribute Details
#pdf_filename ⇒ Object
Returns the value of attribute pdf_filename.
51 52 53 |
# File 'lib/rabbit/html/generator.rb', line 51 def pdf_filename @pdf_filename end |
#source_filename ⇒ Object
Returns the value of attribute source_filename.
51 52 53 |
# File 'lib/rabbit/html/generator.rb', line 51 def source_filename @source_filename end |
Instance Method Details
#index_href(slide_number) ⇒ Object
120 121 122 123 124 |
# File 'lib/rabbit/html/generator.rb', line 120 def index_href() with_outputting_index(true) do href() end end |
#index_image_title(slide_number) ⇒ Object
132 133 134 135 136 137 138 |
# File 'lib/rabbit/html/generator.rb', line 132 def index_image_title() @canvas.with_index_mode(true) do with_outputting_index(true) do image_title() end end end |
#number_of_places(num) ⇒ Object
98 99 100 101 102 103 104 105 106 |
# File 'lib/rabbit/html/generator.rb', line 98 def number_of_places(num) n = 1 target = num while target >= 10 target /= 10 n += 1 end n end |
#output_html? ⇒ Boolean
112 113 114 |
# File 'lib/rabbit/html/generator.rb', line 112 def output_html? @output_html end |
#output_index_html? ⇒ Boolean
108 109 110 |
# File 'lib/rabbit/html/generator.rb', line 108 def output_index_html? @output_index_html end |
#output_slide_html? ⇒ Boolean
116 117 118 |
# File 'lib/rabbit/html/generator.rb', line 116 def output_html? and !@index_mode end |
#outputting_index? ⇒ Boolean
148 149 150 |
# File 'lib/rabbit/html/generator.rb', line 148 def outputting_index? @outputting_index end |
#save ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/rabbit/html/generator.rb', line 70 def save save_environment do @outputting_index = false @canvas. do |, pixbuf, | = _("Creating a image for the %dth page") % @canvas.logger.info() (, pixbuf, ) true end if output_index_html? @canvas.with_index_mode(true) do @canvas..each_with_index do |, | save_index(, ) end end end unless save_rss @canvas.logger.warn(_("can't generate RSS")) end end end |
#save_pixbuf(pixbuf, optional = nil) ⇒ Object
92 93 94 95 96 |
# File 'lib/rabbit/html/generator.rb', line 92 def save_pixbuf(pixbuf, optional=nil) pixbuf.save(pixbuf_filename(@slide_number, optional), normalized_image_type) image_src(@slide_number, optional) end |
#slide_href(slide_number) ⇒ Object
126 127 128 129 130 |
# File 'lib/rabbit/html/generator.rb', line 126 def () with_outputting_index(false) do href() end end |
#slide_image_title(slide_number) ⇒ Object
140 141 142 143 144 145 146 |
# File 'lib/rabbit/html/generator.rb', line 140 def () @canvas.with_index_mode(false) do with_outputting_index(false) do image_title() end end end |
#with_outputting_index(index) ⇒ Object
152 153 154 155 156 157 158 |
# File 'lib/rabbit/html/generator.rb', line 152 def with_outputting_index(index) _index = @outputting_index @outputting_index = index yield ensure @outputting_index = _index end |