Class: TP::SlideDeck

Inherits:
Object
  • Object
show all
Defined in:
lib/tp/slide_deck.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(slides) ⇒ SlideDeck

Returns a new instance of SlideDeck.



5
6
7
8
# File 'lib/tp/slide_deck.rb', line 5

def initialize(slides)
  @cursor = 0
  @slides = slides
end

Instance Attribute Details

#cursorObject (readonly)

Returns the value of attribute cursor.



3
4
5
# File 'lib/tp/slide_deck.rb', line 3

def cursor
  @cursor
end

#slidesObject (readonly)

Returns the value of attribute slides.



3
4
5
# File 'lib/tp/slide_deck.rb', line 3

def slides
  @slides
end

Instance Method Details

#currentObject Also known as: current_frame



10
11
12
# File 'lib/tp/slide_deck.rb', line 10

def current
  frames[cursor]
end

#ended?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/tp/slide_deck.rb', line 15

def ended?
  not current
end

#framesObject



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/tp/slide_deck.rb', line 19

def frames
  return @frames if @frames

  @frames = []

  slides.each do |slide|
    @frames |= slide.frames
  end

  @frames
end

#heightObject



51
52
53
# File 'lib/tp/slide_deck.rb', line 51

def height
  slides.collect(&:height).max
end

#maximum_hard_widthObject



63
64
65
# File 'lib/tp/slide_deck.rb', line 63

def maximum_hard_width
  slides.select(&:hard_width?).collect(&:width).max
end

#maximum_header_lengthObject



55
56
57
# File 'lib/tp/slide_deck.rb', line 55

def maximum_header_length
  slides.collect(&:header).map(&:length).max
end

#maximum_widthObject



59
60
61
# File 'lib/tp/slide_deck.rb', line 59

def maximum_width
  slides.collect(&:width).max
end

#nextObject



31
32
33
34
35
# File 'lib/tp/slide_deck.rb', line 31

def next
  @cursor += 1

  current
end

#previousObject



37
38
39
40
41
# File 'lib/tp/slide_deck.rb', line 37

def previous
  @cursor -= 1

  current
end

#widthObject



43
44
45
46
47
48
49
# File 'lib/tp/slide_deck.rb', line 43

def width
  if maximum_hard_width
    [maximum_header_length, maximum_hard_width].max
  else
    [maximum_width, 80].min
  end
end