class MemeCaptain::CaptionChoice
For comparing different caption line break and pointsize choices.
Attributes
bound_height[RW]
bound_width[RW]
metrics[RW]
pointsize[RW]
text[RW]
Public Class Methods
new(pointsize, metrics, text, bound_width, bound_height)
click to toggle source
# File lib/meme_captain/caption_choice.rb, line 9 def initialize(pointsize, metrics, text, bound_width, bound_height) @pointsize = pointsize @metrics = metrics @text = text @bound_width = bound_width @bound_height = bound_height end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/meme_captain/caption_choice.rb, line 29 def <=>(other) [fits_i, pointsize, fits ? -num_lines : num_lines] <=> [other.fits_i, other.pointsize, other.fits ? -other.num_lines : other.num_lines] end
fits()
click to toggle source
# File lib/meme_captain/caption_choice.rb, line 21 def fits metrics.width <= bound_width && metrics.height <= bound_height end
fits_i()
click to toggle source
# File lib/meme_captain/caption_choice.rb, line 25 def fits_i fits ? 1 : 0 end
num_lines()
click to toggle source
# File lib/meme_captain/caption_choice.rb, line 17 def num_lines text.count("\n") + 1 end