Class: Graff

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

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Graff

Returns a new instance of Graff.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/graff.rb', line 6

def initialize(file)
  if File.directory?(file)
    file = file + "/data.plist"
  end
  
  if File.read(file, 2).unpack('CC') == [0x1f, 0x8b]
    file = Zlib::GzipReader.open(file).read
  end
  
  @stencil = Plist::parse_xml(file)
end

Instance Method Details

#active_layer_indexObject

MAPPINGS



20
21
22
# File 'lib/graff.rb', line 20

def active_layer_index
  @stencil['ActiveLayerIndex']
end

#application_versionObject



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

def application_version
  @stencil['ApplicationVersion']
end

#auto_adjustObject



28
29
30
# File 'lib/graff.rb', line 28

def auto_adjust
  @stencil['AutoAdjust']
end

#background_graphicObject



32
33
34
# File 'lib/graff.rb', line 32

def background_graphic
  @stencil['BackgroundGraphic']
end

#base_zoomObject



36
37
38
# File 'lib/graff.rb', line 36

def base_zoom
  @stencil['BaseZoom']
end

#canvas_originObject



40
41
42
# File 'lib/graff.rb', line 40

def canvas_origin
  @stencil['CanvasOrigin']
end

#column_alignObject



44
45
46
# File 'lib/graff.rb', line 44

def column_align
  @stencil['ColumnAlign']
end

#column_spacingObject



48
49
50
# File 'lib/graff.rb', line 48

def column_spacing
  @stencil['ColumnSpacing']
end

#creation_dateObject



52
53
54
# File 'lib/graff.rb', line 52

def creation_date
  @stencil['CreationDate']
end

#creatorObject



56
57
58
# File 'lib/graff.rb', line 56

def creator
  @stencil['Creator']
end

#display_scaleObject



60
61
62
# File 'lib/graff.rb', line 60

def display_scale
  @stencil['DisplayScale']
end

#graph_document_versionObject



64
65
66
# File 'lib/graff.rb', line 64

def graph_document_version
  @stencil['GraphDocumentVersion']
end

#graphics_listObject



68
69
70
# File 'lib/graff.rb', line 68

def graphics_list
  @stencil['GraphicsList']
end

#grid_infoObject



72
73
74
# File 'lib/graff.rb', line 72

def grid_info
  @stencil['GridInfo']
end

#guides_lockedObject



76
77
78
# File 'lib/graff.rb', line 76

def guides_locked
  @stencil['GuidesLocked']
end

#guides_visibleObject



80
81
82
# File 'lib/graff.rb', line 80

def guides_visible
  @stencil['GuidesVisible']
end

#h_pagesObject



84
85
86
# File 'lib/graff.rb', line 84

def h_pages
  @stencil['HPages']
end

#image_counterObject



88
89
90
# File 'lib/graff.rb', line 88

def image_counter
  @stencil['ImageCounter']
end

#keep_to_scaleObject



92
93
94
# File 'lib/graff.rb', line 92

def keep_to_scale
  @stencil['KeepToScale']
end

#layersObject



96
97
98
# File 'lib/graff.rb', line 96

def layers
  @stencil['Layers']
end

#layout_infoObject



100
101
102
# File 'lib/graff.rb', line 100

def layout_info
  @stencil['LayoutInfo']
end


104
105
106
# File 'lib/graff.rb', line 104

def links_visible
  @stencil['LinksVisible']
end

#magnets_visibleObject



108
109
110
# File 'lib/graff.rb', line 108

def magnets_visible
  @stencil['MagnetsVisible']
end

#master_sheetsObject



112
113
114
# File 'lib/graff.rb', line 112

def master_sheets
  @stencil['MasterSheets']
end

#modification_dateObject



116
117
118
# File 'lib/graff.rb', line 116

def modification_date
  @stencil['ModificationDate']
end

#modifierObject



120
121
122
# File 'lib/graff.rb', line 120

def modifier
  @stencil['Modifier']
end

#notes_visibleObject



124
125
126
# File 'lib/graff.rb', line 124

def notes_visible
  @stencil['NotesVisible']
end

#number_of_canvasesObject



210
211
212
# File 'lib/graff.rb', line 210

def number_of_canvases
  self.sheets ? self.sheets.count : 1
end

#number_of_graphicsObject

CONVENIENCE METHODS



198
199
200
201
202
203
204
205
206
207
208
# File 'lib/graff.rb', line 198

def number_of_graphics
  if self.sheets
    graphics = 0
    self.sheets.each do |sheet|
      graphics = graphics + sheet['GraphicsList'].count
    end
    graphics
  else
    self.graphics_list.count
  end
end

#number_of_layersObject



214
215
216
217
218
219
220
221
222
223
224
# File 'lib/graff.rb', line 214

def number_of_layers
  if self.sheets
    layers = 0
    self.sheets.each do |sheet|
      layers = layers + sheet['Layers'].count
    end
    layers
  else
    self.layers ? self.layers.count : 1
  end
end

#orientationObject



128
129
130
# File 'lib/graff.rb', line 128

def orientation
  @stencil['Orientation']
end

#origin_visibleObject



132
133
134
# File 'lib/graff.rb', line 132

def origin_visible
  @stencil['OriginVisible']
end

#page_breaksObject



136
137
138
# File 'lib/graff.rb', line 136

def page_breaks
  @stencil['PageBreaks']
end


140
141
142
# File 'lib/graff.rb', line 140

def print_info
  @stencil['PrintInfo']
end


144
145
146
# File 'lib/graff.rb', line 144

def print_one_page
  @stencil['PrintOnePage']
end

#read_onlyObject



148
149
150
# File 'lib/graff.rb', line 148

def read_only
  @stencil['ReadOnly']
end

#row_alignObject



152
153
154
# File 'lib/graff.rb', line 152

def row_align
  @stencil['RowAlign']
end

#row_spacingObject



156
157
158
# File 'lib/graff.rb', line 156

def row_spacing
  @stencil['RowSpacing']
end

#sheet_titleObject



160
161
162
# File 'lib/graff.rb', line 160

def sheet_title
  @stencil['SheetTitle']
end

#sheetsObject



164
165
166
# File 'lib/graff.rb', line 164

def sheets
  @stencil['Sheets']
end

#smart_aligment_guides_activeObject



168
169
170
# File 'lib/graff.rb', line 168

def smart_aligment_guides_active
  @stencil['SmartAlignmentGuidesActive']
end

#smart_distance_guides_activeObject



172
173
174
# File 'lib/graff.rb', line 172

def smart_distance_guides_active
  @stencil['SmartDistanceGuidesActive']
end

#unique_idObject



176
177
178
# File 'lib/graff.rb', line 176

def unique_id
  @stencil['UniqueID']
end

#use_entire_pageObject



184
185
186
# File 'lib/graff.rb', line 184

def use_entire_page
  @stencil['UseEntirePage']
end

#v_pagesObject



188
189
190
# File 'lib/graff.rb', line 188

def v_pages
  @stencil['VPages']
end

#versionObject



226
227
228
# File 'lib/graff.rb', line 226

def version
  self.graph_document_version
end

#window_infoObject



192
193
194
# File 'lib/graff.rb', line 192

def window_info
  @stencil['WindowInfo']
end