### Home Classes Methods

### In Files

- lib/prawn/text/formatted/fragment.rb

### Parent

Object

### Methods

- ::new
- #absolute_bottom
- #absolute_bottom_left
- #absolute_bottom_right
- #absolute_bounding_box
- #absolute_left
- #absolute_right
- #absolute_top
- #absolute_top_left
- #absolute_top_right
- #anchor
- #bottom
- #bottom_left
- #bottom_right
- #bounding_box
- #callback_objects
- #character_spacing
- #color
- #default_direction=
- #direction
- #font
- #height
- #include_trailing_white_space!
- #link
- #local
- #right
- #size
- #space_count
- #strikethrough_points
- #styles
- #subscript?
- #superscript?
- #top
- #top_left
- #top_right
- #underline_points
- #width
- #y_offset

### Class/Module Index

Quicksearch

- Prawn
- Prawn::Configurable
- Prawn::Document
- Prawn::Document::BoundingBox
- Prawn::Document::ColumnBox
- Prawn::Document::GraphicsState
- Prawn::Document::Grid
- Prawn::Document::GridBox
- Prawn::Document::Internals
- Prawn::Document::Security
- Prawn::Document::Snapshot
- Prawn::Encoding
- Prawn::Errors
- Prawn::Font
- Prawn::Font::AFM
- Prawn::Font::DFont
- Prawn::Font::TTF
- Prawn::FontMetricCache
- Prawn::Graphics
- Prawn::Graphics::CapStyle
- Prawn::Graphics::Color
- Prawn::Graphics::Dash
- Prawn::Graphics::JoinStyle
- Prawn::Graphics::Patterns
- Prawn::Graphics::Transformation
- Prawn::Graphics::Transparency
- Prawn::ImageHandler
- Prawn::Images
- Prawn::Images::Image
- Prawn::Images::JPG
- Prawn::Images::PNG
- Prawn::Measurements
- Prawn::SoftMask
- Prawn::Stamp
- Prawn::SynchronizedCache
- Prawn::Table
- Prawn::Table::Cell
- Prawn::Table::Cell::Image
- Prawn::Table::Cell::InTable
- Prawn::Table::Cell::SpanDummy
- Prawn::Table::Cell::Subtable
- Prawn::Table::Cell::Text
- Prawn::Table::Cells
- Prawn::Table::ColumnWidthCalculator
- Prawn::Text
- Prawn::Text::Box
- Prawn::Text::Formatted
- Prawn::Text::Formatted::Box
- Prawn::Text::Formatted::Fragment
- Prawn::Text::Formatted::Parser
- Prawn::ThreadLocalCache
- PDF
- PDF::Core
- PDF::Core::Reference
- PDF::Core::Stream
- Arcfour
- Numeric

No matching classes.

# Prawn::Text::Formatted::Fragment

Prawn::Text::Formatted::Fragment is a state store for a formatted text fragment. It does not render anything.

@private

### Attributes

ascender[RW]
baseline[RW]
descender[RW]
format_state[R]
left[RW]
line_height[RW]
text[R]
width[W]
word_spacing[RW]

### Public Class Methods

new(text, format_state, document) click to toggle source

    # File lib/prawn/text/formatted/fragment.rb, line 24
    def initialize(text, format_state, document)
      @format_state = format_state
      @document = document
      @word_spacing = 0

      # keep the original value of "text", so we can reinitialize @text if formatting parameters
      #   like text direction are changed
      @original_text = text
      @text = process_text(@original_text)
    end

### Public Instance Methods

absolute_bottom() click to toggle source

    # File lib/prawn/text/formatted/fragment.rb, line 187
    def absolute_bottom
      absolute_bounding_box[1]
    end

absolute_bottom_left() click to toggle source

    # File lib/prawn/text/formatted/fragment.rb, line 199
    def absolute_bottom_left
      [absolute_left, absolute_bottom]
    end

absolute_bottom_right() click to toggle source

    # File lib/prawn/text/formatted/fragment.rb, line 203
    def absolute_bottom_right
      [absolute_right, absolute_bottom]
    end

absolute_bounding_box() click to toggle source

    # File lib/prawn/text/formatted/fragment.rb, line 64
    def absolute_bounding_box
      box = bounding_box
      box[0] += @document.bounds.absolute_left
      box[2] += @document.bounds.absolute_left
      box[1] += @document.bounds.absolute_bottom
      box[3] += @document.bounds.absolute_bottom
      box
    end

absolute_left() click to toggle source

    # File lib/prawn/text/formatted/fragment.rb, line 175
    def absolute_left
      absolute_bounding_box[0]
    end

absolute_right() click to toggle source

    # File lib/prawn/text/formatted/fragment.rb, line 179
    def absolute_right
      absolute_bounding_box[2]
    end

absolute_top() click to toggle source

    # File lib/prawn/text/formatted/fragment.rb, line 183
    def absolute_top
      absolute_bounding_box[3]
    end

absolute_top_left() click to toggle source

    # File lib/prawn/text/formatted/fragment.rb, line 191
    def absolute_top_left
      [absolute_left, absolute_top]
    end

absolute_top_right() click to toggle source

    # File lib/prawn/text/formatted/fragment.rb, line 195
    def absolute_top_right
      [absolute_right, absolute_top]
    end

anchor() click to toggle source

    # File lib/prawn/text/formatted/fragment.rb, line 91
    def anchor
      @format_state[:anchor]
    end

bottom() click to toggle source

    # File lib/prawn/text/formatted/fragment.rb, line 155
    def bottom
      baseline - descender
    end

bottom_left() click to toggle source

    # File lib/prawn/text/formatted/fragment.rb, line 171
    def bottom_left
      [left, bottom]
    end

bottom_right() click to toggle source

    # File lib/prawn/text/formatted/fragment.rb, line 167
    def bottom_right
      [right, bottom]
    end

bounding_box() click to toggle source

    # File lib/prawn/text/formatted/fragment.rb, line 60
    def bounding_box
      [left, bottom, right, top]
    end

callback_objects() click to toggle source

    # File lib/prawn/text/formatted/fragment.rb, line 136
    def callback_objects
      callback = @format_state[:callback]
      if callback.nil?
        []
      elsif callback.is_a?(Array)
        callback
      else
        [callback]
      end
    end

character_spacing() click to toggle source

    # File lib/prawn/text/formatted/fragment.rb, line 111
    def character_spacing
      @format_state[:character_spacing] ||
        @document.character_spacing
    end

color() click to toggle source

    # File lib/prawn/text/formatted/fragment.rb, line 99
    def color
      @format_state[:color]
    end

default_direction=(direction) click to toggle source

    # File lib/prawn/text/formatted/fragment.rb, line 120
    def default_direction=(direction)
      unless @format_state[:direction]
        @format_state[:direction] = direction
        @text = process_text(@original_text)
      end
    end

direction() click to toggle source

    # File lib/prawn/text/formatted/fragment.rb, line 116
    def direction
      @format_state[:direction]
    end

font() click to toggle source

    # File lib/prawn/text/formatted/fragment.rb, line 103
    def font
      @format_state[:font]
    end

height() click to toggle source

    # File lib/prawn/text/formatted/fragment.rb, line 41
    def height
      top - bottom
    end

include_trailing_white_space!() click to toggle source

    # File lib/prawn/text/formatted/fragment.rb, line 127
    def include_trailing_white_space!
      @format_state.delete(:exclude_trailing_white_space)
      @text = process_text(@original_text)
    end

link() click to toggle source

    # File lib/prawn/text/formatted/fragment.rb, line 87
    def link
      @format_state[:link]
    end

local() click to toggle source

    # File lib/prawn/text/formatted/fragment.rb, line 95
    def local
      @format_state[:local]
    end

right() click to toggle source

    # File lib/prawn/text/formatted/fragment.rb, line 147
    def right
      left + width
    end

size() click to toggle source

    # File lib/prawn/text/formatted/fragment.rb, line 107
    def size
      @format_state[:size]
    end

space_count() click to toggle source

    # File lib/prawn/text/formatted/fragment.rb, line 132
    def space_count
      @text.count(" ")
    end

strikethrough_points() click to toggle source

    # File lib/prawn/text/formatted/fragment.rb, line 78
    def strikethrough_points
      y = baseline + ascender * 0.3
      [[left, y], [right, y]]
    end

styles() click to toggle source

    # File lib/prawn/text/formatted/fragment.rb, line 83
    def styles
      @format_state[:styles] || []
    end

subscript?() click to toggle source

    # File lib/prawn/text/formatted/fragment.rb, line 45
    def subscript?
      styles.include?(:subscript)
    end

superscript?() click to toggle source

    # File lib/prawn/text/formatted/fragment.rb, line 49
    def superscript?
      styles.include?(:superscript)
    end

top() click to toggle source

    # File lib/prawn/text/formatted/fragment.rb, line 151
    def top
      baseline + ascender
    end

top_left() click to toggle source

    # File lib/prawn/text/formatted/fragment.rb, line 159
    def top_left
      [left, top]
    end

top_right() click to toggle source

    # File lib/prawn/text/formatted/fragment.rb, line 163
    def top_right
      [right, top]
    end

underline_points() click to toggle source

    # File lib/prawn/text/formatted/fragment.rb, line 73
    def underline_points
      y = baseline - 1.25
      [[left, y], [right, y]]
    end

width() click to toggle source

    # File lib/prawn/text/formatted/fragment.rb, line 35
    def width
      if @word_spacing == 0 then @width
      else @width + @word_spacing * space_count
      end
    end

y_offset() click to toggle source

    # File lib/prawn/text/formatted/fragment.rb, line 53
    def y_offset
      if subscript? then -descender
      elsif superscript? then 0.85 * ascender
      else 0
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.