Class: Slide

Inherits:
Object
  • Object
show all
Defined in:
lib/wee-pm/presentation.rb

Overview

Each slide consists of one or more overlays.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Slide

Returns a new instance of Slide.

Yields:

  • (_self)

Yield Parameters:

  • _self (Slide)

    the object that the method was called on



121
122
123
124
125
126
127
128
# File 'lib/wee-pm/presentation.rb', line 121

def initialize
  @number_of_overlays = []
  @title = 'unnamed slide'
  @content = ''
  @annotations = '' 
  @style = ''
  yield self if block_given?
end

Instance Attribute Details

#annotationsObject

Returns the value of attribute annotations.



71
72
73
# File 'lib/wee-pm/presentation.rb', line 71

def annotations
  @annotations
end

#contentObject

the rdoc content of the slide (excluding the title)



70
71
72
# File 'lib/wee-pm/presentation.rb', line 70

def content
  @content
end

#converterObject

Returns the value of attribute converter.



72
73
74
# File 'lib/wee-pm/presentation.rb', line 72

def converter
  @converter
end

#styleObject

Returns the value of attribute style.



73
74
75
# File 'lib/wee-pm/presentation.rb', line 73

def style
  @style
end

#titleObject

Returns the value of attribute title.



69
70
71
# File 'lib/wee-pm/presentation.rb', line 69

def title
  @title
end

Class Method Details

.from_string(str) ⇒ Object



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/wee-pm/presentation.rb', line 101

def self.from_string(str)
  new {|s|
    if str =~ /^=([^=].*)$/
      str = $~.post_match
      s.title = $1.strip
    end
    if str =~ /^\w+::/
      s.content = $~.pre_match
      if str =~ /^annotations::(.*)^endannotations::$/m
        s.annotations = $1.strip
      end
      if str =~ /^style::(.*)^endstyle::$/m
        s.style = $1.strip
      end
    else
      s.content = str
    end
  }
end

Instance Method Details

#number_of_overlaysObject



130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/wee-pm/presentation.rb', line 130

def number_of_overlays
  if @content != @number_of_overlays[1]
    # content has changed -> re-calculate the number of overlays
    num = 
    if @content.strip.empty? 
      0
    else
      converter().new.count_overlays(@content)
    end
    @number_of_overlays = [num, @content.dup]
  end
  @number_of_overlays[0]
end

#render_annotations_on(r) ⇒ Object



148
149
150
# File 'lib/wee-pm/presentation.rb', line 148

def render_annotations_on(r)
  converter().new.render_annotations_on(r, @annotations)
end

#render_on(r, overlay) ⇒ Object



144
145
146
# File 'lib/wee-pm/presentation.rb', line 144

def render_on(r, overlay) 
  converter().new.render_on(r, overlay, @content)
end

#to_sObject



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/wee-pm/presentation.rb', line 83

def to_s
  str = "= #{ @title }\n\n" + @content + "\n"
  unless @annotations.strip.empty?
    str << "annotations::\n"
    str << @annotations
    str << "\n"
    str << "endannotations::\n"
  end
  unless @style.strip.empty?
    str << "style::\n"
    str << @style
    str << "\n"
    str << "endstyle::\n"
  end
  str << "\n"
  str
end