Class: Polites::Sheet

Inherits:
Object
  • Object
show all
Defined in:
lib/polites/sheet.rb

Overview

A sheet is represents a single "document" in Polites. It composes the main content in #content, its markup definition in #markup, any attaches files in #files and some metadata.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version:, app_version:, markup:, content:, keywords: [], files: [], notes: []) ⇒ Sheet



36
37
38
39
40
41
42
43
44
# File 'lib/polites/sheet.rb', line 36

def initialize(version:, app_version:, markup:, content:, keywords: [], files: [], notes: [])
  @version = version
  @app_version = app_version
  @markup = markup
  @content = content
  @keywords = keywords
  @files = files
  @notes = notes
end

Instance Attribute Details

#app_versionString (readonly)



12
13
14
# File 'lib/polites/sheet.rb', line 12

def app_version
  @app_version
end

#contentArray<Node> (readonly)



18
19
20
# File 'lib/polites/sheet.rb', line 18

def content
  @content
end

#filesArray<String> (readonly)



24
25
26
# File 'lib/polites/sheet.rb', line 24

def files
  @files
end

#keywordsArray<String> (readonly)



21
22
23
# File 'lib/polites/sheet.rb', line 21

def keywords
  @keywords
end

#markupMarkup (readonly)



15
16
17
# File 'lib/polites/sheet.rb', line 15

def markup
  @markup
end

#notesArray<Array<Node>> (readonly)



27
28
29
# File 'lib/polites/sheet.rb', line 27

def notes
  @notes
end

#versionString (readonly)



9
10
11
# File 'lib/polites/sheet.rb', line 9

def version
  @version
end

Instance Method Details

#attached_filesArray<String>

Get all files that were attached to the sheet without explicit mention in the content.



59
60
61
# File 'lib/polites/sheet.rb', line 59

def attached_files
  files - inline_files.map(&:image)
end

#inline_filesArray<Span::Image>

Get all files that were referenced in the content, such as inline images.



49
50
51
52
53
# File 'lib/polites/sheet.rb', line 49

def inline_files
  content.flat_map do |node|
    node.children.grep(Span::Image)
  end
end