Module: RubyBeamer
- Defined in:
- lib/ruby-beamer.rb,
lib/ruby-beamer/text.rb,
lib/ruby-beamer/beamer.rb,
lib/ruby-beamer/common.rb,
lib/ruby-beamer/constants.rb,
lib/ruby-beamer/create-beamer-doc.rb
Defined Under Namespace
Classes: Hash
Constant Summary collapse
- VERSION =
'0.0.1'- ONE_LINERS =
{ :bold => :textbf, :em => :em, :huge => :huge, :footnote => :footnotesize, :teletype => :tt, :structure => :structure, :vspace => :vspace, :only => :only }
- TEXT_WIDTH =
"\\textwidth"- TEXT_HEIGHT =
"\\textheight"- PAGE_WIDTH =
"\\pagewidth"- PAGE_HEIGHT =
"\\pageheight"- NEWLINE =
"\\\\"- SECTION =
"\\insertsection"- SUB_SECTION =
"\\insertsubsection"
Instance Method Summary collapse
- #__beamer_get_options(*args) ⇒ Object
- #__get_property_options(properties) ⇒ Object
- #__output_line_from(args, property) ⇒ Object
- #__print_block(starting, separator, content_start, ending, args, &block) ⇒ Object
- #__wrap_in_section(type, title, &block) ⇒ Object
- #beamer_document(args = {}, &block) ⇒ Object
- #block(title, *args, &passed_block) ⇒ Object
- #center(*args, &block) ⇒ Object
- #create_block(type, args = {}, &block) ⇒ Object
- #create_oneline_block(type, args = {}, &block) ⇒ Object
- #frame(title = nil, *args, &block) ⇒ Object
- #image(path, *arguments) ⇒ Object
- #item(*args, &block) ⇒ Object
- #itemized_list(*args, &block) ⇒ Object
- #method_missing(method, *args, &block) ⇒ Object
- #new_line ⇒ Object
- #resize_box(width, height, *args, &block) ⇒ Object
- #responds_to?(method) ⇒ Boolean
- #section(title, &block) ⇒ Object
- #sub_section(title, &block) ⇒ Object
- #table_of_contents_frame(title, *arguments) ⇒ Object
- #text ⇒ Object
- #title_frame(*args) ⇒ Object
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
17 18 19 20 |
# File 'lib/ruby-beamer/text.rb', line 17 def method_missing(method, *args, &block) return super if not ONE_LINERS.has_key? method create_oneline_block(ONE_LINERS[method], args.to_beamer_hash, &block) end |
Instance Method Details
#__beamer_get_options(*args) ⇒ Object
36 37 38 39 40 |
# File 'lib/ruby-beamer/common.rb', line 36 def (*args) values = args.to_beamer_hash.inject([]) {|values, tuple| values << "#{tuple[0]}#{"=" if tuple[1]}#{tuple[1]}" } return "" if values.empty? return "[" + values.join(",") + "]" end |
#__get_property_options(properties) ⇒ Object
2 3 4 5 6 |
# File 'lib/ruby-beamer/create-beamer-doc.rb', line 2 def (properties) return nil if not properties return "{#{properties}}" if properties.is_a? String return "[#{properties[0]}]{#{properties[1]}}" end |
#__output_line_from(args, property) ⇒ Object
8 9 10 11 |
# File 'lib/ruby-beamer/create-beamer-doc.rb', line 8 def __output_line_from(args, property) = args[property] output "\\#{property}#{}\n" if end |
#__print_block(starting, separator, content_start, ending, args, &block) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/ruby-beamer/common.rb', line 42 def __print_block(starting, separator, content_start, ending, args, &block) block_args = (args.delete :arguments) || "" appear_on = ("<#{args.delete :on}>" if args.has_key? :on) || "" output starting, appear_on, block_args, separator, content_start content = yield if block output content, separator if content output ending, "\n" end |
#__wrap_in_section(type, title, &block) ⇒ Object
42 43 44 45 46 |
# File 'lib/ruby-beamer/beamer.rb', line 42 def __wrap_in_section(type, title, &block) create_oneline_block(type) {title} content = yield if block output content, "\n" if content end |
#beamer_document(args = {}, &block) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ruby-beamer/create-beamer-doc.rb', line 13 def beamer_document(args = {}, &block) theme = args[:theme] || "default" = args[:global_options] output "\\documentclass", ("[#{}]" if ) || "", "{beamer}\n" output "\\usetheme{#{theme}}\n" __output_line_from args, :title __output_line_from args, :subtitle __output_line_from args, :author __output_line_from args, :date output "\\setbeamertemplate{navigation symbols}{}\n" if args[:disable_navigation] create_block :document, &block end |
#block(title, *args, &passed_block) ⇒ Object
6 7 8 |
# File 'lib/ruby-beamer/beamer.rb', line 6 def block(title, *args, &passed_block) create_block(:block, args.to_beamer_hash.merge!(:arguments => "{#{title}}"), &passed_block) end |
#center(*args, &block) ⇒ Object
2 3 4 |
# File 'lib/ruby-beamer/text.rb', line 2 def center(*args, &block) create_block(:center, args.to_beamer_hash, &block) end |
#create_block(type, args = {}, &block) ⇒ Object
52 53 54 |
# File 'lib/ruby-beamer/common.rb', line 52 def create_block(type, args = {}, &block) __print_block("\\begin{#{type}}", "\n", "", "\\end{#{type}}", args, &block) end |
#create_oneline_block(type, args = {}, &block) ⇒ Object
56 57 58 |
# File 'lib/ruby-beamer/common.rb', line 56 def create_oneline_block(type, args = {}, &block) __print_block("\\#{type}", "", "{", "}", args, &block) end |
#frame(title = nil, *args, &block) ⇒ Object
2 3 4 |
# File 'lib/ruby-beamer/beamer.rb', line 2 def frame(title = nil, *args, &block) create_block(:frame, args.to_beamer_hash.merge!(:arguments => "{#{title}}"), &block) end |
#image(path, *arguments) ⇒ Object
36 37 38 39 40 |
# File 'lib/ruby-beamer/beamer.rb', line 36 def image(path, *arguments) hash = arguments.to_beamer_hash hash.set_beamer_arguments_from(:width, :height) create_oneline_block(:includegraphics, hash) { path } end |
#item(*args, &block) ⇒ Object
18 19 20 21 22 |
# File 'lib/ruby-beamer/beamer.rb', line 18 def item(*args, &block) text = args.shift if args[0].is_a? String block = lambda { text } if text create_oneline_block(:item, args.to_beamer_hash, &block) end |
#itemized_list(*args, &block) ⇒ Object
14 15 16 |
# File 'lib/ruby-beamer/beamer.rb', line 14 def itemized_list(*args, &block) create_block(:itemize, args.to_beamer_hash, &block) end |
#new_line ⇒ Object
65 66 67 |
# File 'lib/ruby-beamer/common.rb', line 65 def new_line text { "\\\\" } end |
#resize_box(width, height, *args, &block) ⇒ Object
10 11 12 |
# File 'lib/ruby-beamer/beamer.rb', line 10 def resize_box(width, height, *args, &block) create_oneline_block(:resizebox, args.to_beamer_hash.merge!(:arguments => "{#{width}}{#{height}}"), &block) end |
#responds_to?(method) ⇒ Boolean
22 23 24 |
# File 'lib/ruby-beamer/text.rb', line 22 def responds_to?(method) super or ONE_LINERS.has_key? method end |
#section(title, &block) ⇒ Object
48 49 50 |
# File 'lib/ruby-beamer/beamer.rb', line 48 def section(title, &block) __wrap_in_section(:section, title, &block) end |
#sub_section(title, &block) ⇒ Object
52 53 54 |
# File 'lib/ruby-beamer/beamer.rb', line 52 def sub_section(title, &block) __wrap_in_section(:subsection, title, &block) end |
#table_of_contents_frame(title, *arguments) ⇒ Object
30 31 32 33 34 |
# File 'lib/ruby-beamer/beamer.rb', line 30 def table_of_contents_frame(title, *arguments) hash = arguments.to_beamer_hash hash.set_beamer_arguments_from :currentsection, :hideothersubsections, :section, :hideallsubsections frame(title) { create_oneline_block(:tableofcontents, hash) } end |
#text ⇒ Object
60 61 62 63 |
# File 'lib/ruby-beamer/common.rb', line 60 def text content = yield output content if content end |
#title_frame(*args) ⇒ Object
24 25 26 27 28 |
# File 'lib/ruby-beamer/beamer.rb', line 24 def title_frame(*args) hash = args.to_beamer_hash hash.set_beamer_arguments_from :plain create_block(:frame, hash) { "\\titlepage" } end |