Class: Przn::Presentation
- Inherits:
-
Object
- Object
- Przn::Presentation
- Defined in:
- lib/przn/presentation.rb
Instance Attribute Summary collapse
-
#current ⇒ Object
readonly
Returns the value of attribute current.
-
#slides ⇒ Object
readonly
Returns the value of attribute slides.
Instance Method Summary collapse
- #current_slide ⇒ Object
- #first_slide! ⇒ Object
- #first_slide? ⇒ Boolean
- #go_to(n) ⇒ Object
-
#initialize(slides) ⇒ Presentation
constructor
A new instance of Presentation.
- #last_slide! ⇒ Object
- #last_slide? ⇒ Boolean
- #next_slide ⇒ Object
- #prev_slide ⇒ Object
- #total ⇒ Object
Constructor Details
#initialize(slides) ⇒ Presentation
Returns a new instance of Presentation.
7 8 9 10 |
# File 'lib/przn/presentation.rb', line 7 def initialize() @slides = .freeze @current = 0 end |
Instance Attribute Details
#current ⇒ Object (readonly)
Returns the value of attribute current.
5 6 7 |
# File 'lib/przn/presentation.rb', line 5 def current @current end |
#slides ⇒ Object (readonly)
Returns the value of attribute slides.
5 6 7 |
# File 'lib/przn/presentation.rb', line 5 def @slides end |
Instance Method Details
#current_slide ⇒ Object
12 |
# File 'lib/przn/presentation.rb', line 12 def = [current] |
#first_slide! ⇒ Object
29 30 31 |
# File 'lib/przn/presentation.rb', line 29 def @current = 0 end |
#first_slide? ⇒ Boolean
14 |
# File 'lib/przn/presentation.rb', line 14 def = current == 0 |
#go_to(n) ⇒ Object
25 26 27 |
# File 'lib/przn/presentation.rb', line 25 def go_to(n) @current = n.clamp(0, total - 1) end |
#last_slide! ⇒ Object
33 34 35 |
# File 'lib/przn/presentation.rb', line 33 def @current = total - 1 end |
#last_slide? ⇒ Boolean
15 |
# File 'lib/przn/presentation.rb', line 15 def = current == total - 1 |
#next_slide ⇒ Object
17 18 19 |
# File 'lib/przn/presentation.rb', line 17 def @current = [current + 1, total - 1].min end |
#prev_slide ⇒ Object
21 22 23 |
# File 'lib/przn/presentation.rb', line 21 def @current = [current - 1, 0].max end |
#total ⇒ Object
13 |
# File 'lib/przn/presentation.rb', line 13 def total = .size |