Module: Graffle::Document

Includes:
Builders
Defined in:
lib/graffle/stereotypes.rb

Overview

An entire Graffle file, parsed. The only thing of interest is an array of objects stereotyped as Sheet. A Sheet is the internal name for what the OmniGraffle Pro GUI calls “canvases.”

OmniGraffle non-Pro can only produce one-canvas documents.

Some one-canvas OmniGraffle documents don’t actually have Sheets. So that you don’t have to worry about that, a one-element Sheet array is inserted if needed.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Builders

#abstract_graphic, #annotation, classed, #document, #group, #line_graphic, #line_label, raw, #shaped_graphic, #sheet, #text

Class Method Details

.takes_on(hash) ⇒ Object

:nodoc:



174
175
176
177
178
179
180
181
# File 'lib/graffle/stereotypes.rb', line 174

def self.takes_on(hash) # :nodoc: 
  doc = hash.behave_like(self)
  doc.make_sure_has_sheets
  doc.sheets.each do | child |
    Sheet.takes_on(child)
  end
  true
end

Instance Method Details

#first_sheetObject



164
# File 'lib/graffle/stereotypes.rb', line 164

def first_sheet; sheets[0]; end

#make_sure_has_sheetsObject

If this is a graffle document with an implicit single sheet, make it explicit. MISSING: This destroys the structure of the file, so it should not now be written.



188
189
190
191
# File 'lib/graffle/stereotypes.rb', line 188

def make_sure_has_sheets # :nodoc: 
  splice_in_single_sheet unless self.has_key?('Sheets')
  self
end

#sheetsObject



163
# File 'lib/graffle/stereotypes.rb', line 163

def sheets; self['Sheets']; end

#with(*objects) ⇒ Object

:nodoc:



167
168
169
170
171
172
# File 'lib/graffle/stereotypes.rb', line 167

def with(*objects) # :nodoc: 
  self['Sheets'] = [] unless self.has_key?('Sheets')
  objects.each do | o |
    self['Sheets'] << o
  end
end