Class: PdfExtract::AbstractView

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

Direct Known Subclasses

PdfView, XmlView

Constant Summary collapse

@@auto_colors =
["ff0000", "00ff00", "0000ff", "ffff00",
"ff7f00", "ffc0cb", "800080", "f0e68c",
"a52a2a"]

Instance Method Summary collapse

Constructor Details

#initialize(pdf, filename) ⇒ AbstractView

Returns a new instance of AbstractView.



8
9
10
11
# File 'lib/view/abstract_view.rb', line 8

def initialize pdf, filename
  @pdf = pdf
  @filename = filename
end

Instance Method Details

#auto_colorObject



19
20
21
22
23
24
# File 'lib/view/abstract_view.rb', line 19

def auto_color
  @next_auto_color = 0 if @next_auto_color.nil?
  color = @@auto_colors[@next_auto_color]
  @next_auto_color = @next_auto_color.next
  color
end

#objectsObject

Return renderable objects - those whose spatials method was called explicitly.



15
16
17
# File 'lib/view/abstract_view.rb', line 15

def objects
  @pdf.spatial_objects.reject { |type, _| not @pdf.explicit_call? type }
end

#singular_name(name) ⇒ Object



26
27
28
29
# File 'lib/view/abstract_view.rb', line 26

def singular_name name
  name = name.sub /ies$/, 'y'
  name = name.sub /s$/, ''
end