Class: Przn::Slide

Inherits:
Object
  • Object
show all
Defined in:
lib/przn/slide.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(blocks) ⇒ Slide

Returns a new instance of Slide.



7
8
9
# File 'lib/przn/slide.rb', line 7

def initialize(blocks)
  @blocks = blocks.freeze
end

Instance Attribute Details

#blocksObject (readonly)

Returns the value of attribute blocks.



5
6
7
# File 'lib/przn/slide.rb', line 5

def blocks
  @blocks
end

Instance Method Details

#notesObject

Aggregate every ‘note` / `<note>` segment in the slide’s text-bearing fields. The presenter view renders these in its side panel; the audience renderer strips them from the rendered output.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/przn/slide.rb', line 14

def notes
  out = []
  blocks.each do |b|
    texts = []
    texts << b[:content] if b[:content].is_a?(String)
    texts << b[:term]    if b[:term].is_a?(String)
    texts << b[:definition] if b[:definition].is_a?(String)
    if b[:items].is_a?(Array)
      b[:items].each { |it| texts << it[:text] if it.is_a?(Hash) && it[:text].is_a?(String) }
    end
    if b[:rows].is_a?(Array)
      (Array(b[:header]) + b[:rows].flatten).each { |c| texts << c if c.is_a?(String) }
    end
    texts.each do |text|
      Parser.parse_inline(text).each do |seg|
        out << seg[1] if seg[0] == :note && seg[1] && !seg[1].empty?
      end
    end
  end
  out
end