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.
37
38
39
|
# File 'lib/arrolio/flowable.rb', line 37
def initialize(style: Style::Definition.new)
@style = style
end
|
Instance Attribute Details
#style ⇒ Object
Returns the value of attribute style.
35
36
37
|
# File 'lib/arrolio/flowable.rb', line 35
def style
@style
end
|
Instance Method Details
#do_split(_width, _remaining_height, _context = nil) ⇒ Object
97
98
99
|
# File 'lib/arrolio/flowable.rb', line 97
def do_split(_width, _remaining_height, _context = nil)
[self, nil]
end
|
#emit(_x, _y, _width, _context = nil) ⇒ Object
45
46
47
|
# File 'lib/arrolio/flowable.rb', line 45
def emit(_x, _y, _width, _context = nil)
raise NotImplementedError, "#{self.class}#emit not implemented"
end
|
#height(_width, _context = nil) ⇒ Object
41
42
43
|
# File 'lib/arrolio/flowable.rb', line 41
def height(_width, _context = nil)
raise NotImplementedError, "#{self.class}#height not implemented"
end
|
#keep_together? ⇒ Boolean
53
54
55
|
# File 'lib/arrolio/flowable.rb', line 53
def keep_together?
@style.keep_together
end
|
#keep_with_next? ⇒ Boolean
57
58
59
|
# File 'lib/arrolio/flowable.rb', line 57
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.
64
65
66
|
# File 'lib/arrolio/flowable.rb', line 64
def min_keep_height(width, context = nil)
height(width, context)
end
|
#page_break_after? ⇒ Boolean
72
73
74
|
# File 'lib/arrolio/flowable.rb', line 72
def page_break_after?
@style.page_break_after
end
|
#page_break_before? ⇒ Boolean
68
69
70
|
# File 'lib/arrolio/flowable.rb', line 68
def page_break_before?
@style.page_break_before
end
|
#space_after ⇒ Object
80
81
82
|
# File 'lib/arrolio/flowable.rb', line 80
def space_after
@style.margin_bottom
end
|
#space_before ⇒ Object
76
77
78
|
# File 'lib/arrolio/flowable.rb', line 76
def space_before
@style.margin_top
end
|
#split(width, remaining_height, context = nil) ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/arrolio/flowable.rb', line 84
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
49
50
51
|
# File 'lib/arrolio/flowable.rb', line 49
def splittable?
false
end
|