Class: Arrolio::Flowable
- Inherits:
-
Object
show all
- Defined in:
- lib/arrolio/flowable.rb
Direct Known Subclasses
Arrolio::Flowables::FootnoteMarkerFlowable, Arrolio::Flowables::GroupFlowable, Arrolio::Flowables::ImageFlowable, Arrolio::Flowables::ListFlowable, Arrolio::Flowables::PageBreak, Arrolio::Flowables::PageSequenceStart, Arrolio::Flowables::PositionedBlock, Arrolio::Flowables::RotatedText, Arrolio::Flowables::Spacer, Arrolio::Flowables::TableFlowable, Arrolio::Flowables::TextFlowable, Arrolio::Flowables::TocLineFlowable, Arrolio::Flowables::TwoColumnBlock
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#do_split(_width, _remaining_height, _context = nil) ⇒ Object
-
#emit(_x, _y, _width, _context = nil) ⇒ Object
-
#height(_width, _context = nil) ⇒ Object
-
#initialize(style: Style::Definition.new) ⇒ Flowable
constructor
A new instance of Flowable.
-
#keep_together? ⇒ Boolean
-
#keep_with_next? ⇒ Boolean
-
#min_keep_height(width, context = nil) ⇒ Object
Height that must stay on the same page as a preceding keep-with-next flowable: the whole flowable when atomic, the first line (plus space-before) when splittable.
-
#page_break_after? ⇒ Boolean
-
#page_break_before? ⇒ Boolean
-
#space_after ⇒ Object
-
#space_before ⇒ Object
-
#split(width, remaining_height, context = nil) ⇒ Object
-
#splittable? ⇒ Boolean
Constructor Details
#initialize(style: Style::Definition.new) ⇒ Flowable
Returns a new instance of Flowable.
23
24
25
|
# File 'lib/arrolio/flowable.rb', line 23
def initialize(style: Style::Definition.new)
@style = style
end
|
Instance Attribute Details
#style ⇒ Object
Returns the value of attribute style.
21
22
23
|
# File 'lib/arrolio/flowable.rb', line 21
def style
@style
end
|
Instance Method Details
#do_split(_width, _remaining_height, _context = nil) ⇒ Object
83
84
85
|
# File 'lib/arrolio/flowable.rb', line 83
def do_split(_width, _remaining_height, _context = nil)
[self, nil]
end
|
#emit(_x, _y, _width, _context = nil) ⇒ Object
31
32
33
|
# File 'lib/arrolio/flowable.rb', line 31
def emit(_x, _y, _width, _context = nil)
raise NotImplementedError, "#{self.class}#emit not implemented"
end
|
#height(_width, _context = nil) ⇒ Object
27
28
29
|
# File 'lib/arrolio/flowable.rb', line 27
def height(_width, _context = nil)
raise NotImplementedError, "#{self.class}#height not implemented"
end
|
#keep_together? ⇒ Boolean
39
40
41
|
# File 'lib/arrolio/flowable.rb', line 39
def keep_together?
@style.keep_together
end
|
#keep_with_next? ⇒ Boolean
43
44
45
|
# File 'lib/arrolio/flowable.rb', line 43
def keep_with_next?
@style.keep_with_next
end
|
#min_keep_height(width, context = nil) ⇒ Object
Height that must stay on the same page as a preceding
keep-with-next flowable: the whole flowable when atomic, the
first line (plus space-before) when splittable.
50
51
52
|
# File 'lib/arrolio/flowable.rb', line 50
def min_keep_height(width, context = nil)
height(width, context)
end
|
#page_break_after? ⇒ Boolean
58
59
60
|
# File 'lib/arrolio/flowable.rb', line 58
def page_break_after?
@style.page_break_after
end
|
#page_break_before? ⇒ Boolean
54
55
56
|
# File 'lib/arrolio/flowable.rb', line 54
def page_break_before?
@style.page_break_before
end
|
#space_after ⇒ Object
66
67
68
|
# File 'lib/arrolio/flowable.rb', line 66
def space_after
@style.margin_bottom
end
|
#space_before ⇒ Object
62
63
64
|
# File 'lib/arrolio/flowable.rb', line 62
def space_before
@style.margin_top
end
|
#split(width, remaining_height, context = nil) ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/arrolio/flowable.rb', line 70
def split(width, remaining_height, context = nil)
natural = height(width, context)
if natural <= remaining_height
[self, nil]
elsif splittable?
do_split(width, remaining_height, context)
elsif keep_together?
[nil, self]
else
[self, nil]
end
end
|
#splittable? ⇒ Boolean
35
36
37
|
# File 'lib/arrolio/flowable.rb', line 35
def splittable?
false
end
|