Class: Slyde::Presentation
- Inherits:
-
Object
- Object
- Slyde::Presentation
- Defined in:
- lib/slyde/presentation.rb
Defined Under Namespace
Classes: Parser
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
- #index_for_slide(slide) ⇒ Object
-
#initialize(path) ⇒ Presentation
constructor
A new instance of Presentation.
- #parser ⇒ Object
- #raw_html ⇒ Object
- #slide_after(slide) ⇒ Object
- #slide_before(slide) ⇒ Object
- #slide_with_id(id) ⇒ Object
- #slides ⇒ Object
- #title ⇒ Object
- #to_html ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(path) ⇒ Presentation
Returns a new instance of Presentation.
20 21 22 |
# File 'lib/slyde/presentation.rb', line 20 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/slyde/presentation.rb', line 5 def path @path end |
Class Method Details
.renderer ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/slyde/presentation.rb', line 9 def self.renderer @renderer ||= Redcarpet::Markdown.new(HTMLRenderer, { tables: true, fenced_code_blocks: true, autolink: true, strikethrough: true, space_after_headers: true, superscript: true }) end |
Instance Method Details
#index_for_slide(slide) ⇒ Object
65 66 67 |
# File 'lib/slyde/presentation.rb', line 65 def () .index() end |
#parser ⇒ Object
36 37 38 |
# File 'lib/slyde/presentation.rb', line 36 def parser @parser ||= Parser.new(raw_html) end |
#raw_html ⇒ Object
48 49 50 |
# File 'lib/slyde/presentation.rb', line 48 def raw_html self.class.renderer.render(to_s) end |
#slide_after(slide) ⇒ Object
56 57 58 |
# File 'lib/slyde/presentation.rb', line 56 def () [() + 1] end |
#slide_before(slide) ⇒ Object
60 61 62 63 |
# File 'lib/slyde/presentation.rb', line 60 def () index = () index == 0 ? nil : [index - 1] end |
#slide_with_id(id) ⇒ Object
24 25 26 |
# File 'lib/slyde/presentation.rb', line 24 def (id) .find { |s| s.id == id } end |
#slides ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/slyde/presentation.rb', line 28 def @slides ||= parser..each_with_index.map do |, index| = .merge(page: index + 1) Slide.new() end end |
#title ⇒ Object
40 41 42 |
# File 'lib/slyde/presentation.rb', line 40 def title parser.title end |
#to_html ⇒ Object
44 45 46 |
# File 'lib/slyde/presentation.rb', line 44 def to_html @to_html ||= .map(&:to_html).join end |
#to_s ⇒ Object
52 53 54 |
# File 'lib/slyde/presentation.rb', line 52 def to_s File.read(path) end |