lib/prawn/text/box.rb in prawn-2.1.0 vs lib/prawn/text/box.rb in prawn-2.2.0
- old
+ new
@@ -1,15 +1,13 @@
-# encoding: utf-8
-
# text/rectangle.rb : Implements text boxes
#
# Copyright November 2009, Daniel Nelson. All Rights Reserved.
#
# This is free software. Please see the LICENSE and COPYING files for details.
#
-require_relative "formatted/box"
+require_relative 'formatted/box'
module Prawn
module Text
# @group Stable API
@@ -50,11 +48,12 @@
#
# <tt>:at</tt>::
# <tt>[x, y]</tt>. The upper left corner of the box
# [@document.bounds.left, @document.bounds.top]
# <tt>:width</tt>::
- # <tt>number</tt>. The width of the box [@document.bounds.right - @at[0]]
+ # <tt>number</tt>. The width of the box
+ # [@document.bounds.right - @at[0]]
# <tt>:height</tt>::
# <tt>number</tt>. The height of the box [default_height()]
# <tt>:direction</tt>::
# <tt>:ltr</tt>, <tt>:rtl</tt>, Direction of the text (left-to-right
# or right-to-left) [value of document.text_direction]
@@ -80,11 +79,12 @@
# to rotate the text [:upper_left]
# <tt>:leading</tt>::
# <tt>number</tt>. Additional space between lines [value of
# document.default_leading]
# <tt>:single_line</tt>::
- # <tt>boolean</tt>. If true, then only the first line will be drawn [false]
+ # <tt>boolean</tt>. If true, then only the first line will be drawn
+ # [false]
# <tt>:overflow</tt>::
# <tt>:truncate</tt>, <tt>:shrink_to_fit</tt>, or <tt>:expand</tt>
# This controls the behavior when the amount of text
# exceeds the available space. [:truncate]
# <tt>:min_font_size</tt>::
@@ -103,13 +103,14 @@
#
def text_box(string, options = {})
options = options.dup
options[:document] = self
- box = if p = options.delete(:inline_format)
+ box = if options[:inline_format]
+ p = options.delete(:inline_format)
p = [] unless p.is_a?(Array)
- array = self.text_formatter.format(string, *p)
+ array = text_formatter.format(string, *p)
Text::Formatted::Box.new(array, options)
else
Text::Box.new(string, options)
end
@@ -124,10 +125,10 @@
# to placing text on the page, or to determine how much vertical space was
# consumed by the printed text
#
class Box < Prawn::Text::Formatted::Box
def initialize(string, options = {})
- super([{ :text => string }], options)
+ super([{ text: string }], options)
end
def render(flags = {})
leftover = super(flags)
leftover.collect { |hash| hash[:text] }.join