Class: PDFGen::BaseRegion

Inherits:
Object
  • Object
show all
Includes:
BaseAttributes
Defined in:
lib/base_region.rb

Direct Known Subclasses

Caption, Div, Document, Image, Span, Table

Instance Attribute Summary collapse

Attributes included from BaseAttributes

#background_color, #border_bottom, #border_color, #border_left, #border_right, #border_style, #border_top, #border_width, #height, #is_breakable, #pad_bottom, #pad_left, #pad_right, #pad_top, #page_pad_top, #width

Instance Method Summary collapse

Methods included from BaseAttributes

#av_width, #border=, #border_params, #breakable?, included, #paddings=, #var_init

Methods included from BaseAttributes::ClassMethods

#common_setter

Constructor Details

#initialize(parent) ⇒ BaseRegion

Returns a new instance of BaseRegion.



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

def initialize(parent)
  self.var_init
  @parent = parent
end

Instance Attribute Details

#parentObject (readonly)

Returns the value of attribute parent.



13
14
15
# File 'lib/base_region.rb', line 13

def parent
  @parent
end

Instance Method Details

#check_fit_in_heightObject



82
83
84
85
86
# File 'lib/base_region.rb', line 82

def check_fit_in_height
  if (self.height >= document.pdf.page_height-document.page_pad_top)
    raise "There is too little space for this region on this page"
  end
end

#documentObject

gets region’s document



16
17
18
# File 'lib/base_region.rb', line 16

def document
  parent ? parent.document : self
end

#minimal_heightObject

gets minimal height that current caption can be written to



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

def minimal_height
  @minimal_height ||= calculate_minimal_height
end

#render(pos, av_height, test = false) ⇒ Object



76
77
78
79
80
# File 'lib/base_region.rb', line 76

def render(pos,av_height, test=false)
  fill(pos) unless test
  add_border(pos) unless test
  [pos,true]
end

#set_properties(props = {}) ⇒ Object

sets region properties specified as array



93
94
95
# File 'lib/base_region.rb', line 93

def set_properties(props = {})
  props.each_pair {|name, value| self.send("#{name}=", value)}
end

#value(val) ⇒ Object



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

def value val
  "<!#{val.to_s}!>"
end