Class: Crawdad::Breakpoint
- Inherits:
-
Object
- Object
- Crawdad::Breakpoint
- Defined in:
- lib/crawdad/breakpoint.rb
Overview
A node in the breakpoint list.
Instance Attribute Summary collapse
-
#fitness_class ⇒ Object
readonly
Fitness class (0=tight, 1=normal, 2=loose, 3=very loose) of the line ending at this breakpoint.
-
#line ⇒ Object
readonly
Number of the line ending at this breakpoint.
-
#position ⇒ Object
Index of this breakpoint within the sequence of items.
-
#previous ⇒ Object
readonly
Link to the best preceding breakpoint.
-
#ratio ⇒ Object
readonly
The ratio of stretch or shrink used for the line ending at this breakpoint.
-
#total_demerits ⇒ Object
readonly
Minimum total demerits up to this breakpoint.
-
#total_shrink ⇒ Object
readonly
Total shrink up to after(self).
-
#total_stretch ⇒ Object
readonly
Total stretch up to after(self).
-
#total_width ⇒ Object
readonly
Total width up to after(self).
Class Method Summary collapse
-
.starting_node ⇒ Object
Returns the node used for the head of the active list – represents the starting point.
Instance Method Summary collapse
-
#initialize(position, line, fitness_class, total_width, total_stretch, total_shrink, total_demerits, ratio, previous) ⇒ Breakpoint
constructor
Creates a breakpoint node with the given parameters.
- #inspect ⇒ Object
Constructor Details
#initialize(position, line, fitness_class, total_width, total_stretch, total_shrink, total_demerits, ratio, previous) ⇒ Breakpoint
Creates a breakpoint node with the given parameters.
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/crawdad/breakpoint.rb', line 24 def initialize(position, line, fitness_class, total_width, total_stretch, total_shrink, total_demerits, ratio, previous) @position = position @line = line @fitness_class = fitness_class @total_width = total_width @total_stretch = total_stretch @total_shrink = total_shrink @total_demerits = total_demerits @ratio = ratio @previous = previous end |
Instance Attribute Details
#fitness_class ⇒ Object (readonly)
Fitness class (0=tight, 1=normal, 2=loose, 3=very loose) of the line ending at this breakpoint.
48 49 50 |
# File 'lib/crawdad/breakpoint.rb', line 48 def fitness_class @fitness_class end |
#line ⇒ Object (readonly)
Number of the line ending at this breakpoint.
43 44 45 |
# File 'lib/crawdad/breakpoint.rb', line 43 def line @line end |
#position ⇒ Object
Index of this breakpoint within the sequence of items.
39 40 41 |
# File 'lib/crawdad/breakpoint.rb', line 39 def position @position end |
#previous ⇒ Object (readonly)
Link to the best preceding breakpoint.
74 75 76 |
# File 'lib/crawdad/breakpoint.rb', line 74 def previous @previous end |
#ratio ⇒ Object (readonly)
The ratio of stretch or shrink used for the line ending at this breakpoint. 0 is a perfect fit; +1 means 100% of the stretch has been used; -1 means all of the shrink has been used.
70 71 72 |
# File 'lib/crawdad/breakpoint.rb', line 70 def ratio @ratio end |
#total_demerits ⇒ Object (readonly)
Minimum total demerits up to this breakpoint.
64 65 66 |
# File 'lib/crawdad/breakpoint.rb', line 64 def total_demerits @total_demerits end |
#total_shrink ⇒ Object (readonly)
Total shrink up to after(self). Used to calculate adjustment ratios.
60 61 62 |
# File 'lib/crawdad/breakpoint.rb', line 60 def total_shrink @total_shrink end |
#total_stretch ⇒ Object (readonly)
Total stretch up to after(self). Used to calculate adjustment ratios.
56 57 58 |
# File 'lib/crawdad/breakpoint.rb', line 56 def total_stretch @total_stretch end |
#total_width ⇒ Object (readonly)
Total width up to after(self). Used to calculate adjustment ratios.
52 53 54 |
# File 'lib/crawdad/breakpoint.rb', line 52 def total_width @total_width end |
Class Method Details
.starting_node ⇒ Object
Returns the node used for the head of the active list – represents the starting point.
17 18 19 20 |
# File 'lib/crawdad/breakpoint.rb', line 17 def self.starting_node new(position=0, line=0, fitness_class=1, total_width=0, total_stretch=0, total_shrink=0, total_demerits=0, ratio=0.0, previous=nil) end |
Instance Method Details
#inspect ⇒ Object
76 77 78 |
# File 'lib/crawdad/breakpoint.rb', line 76 def inspect "#<Breakpoint position=#{@position} ratio=#{@ratio}>" end |