class Hershey::Word

Attributes

characters[R]

Public Class Methods

new(text, options = {}) click to toggle source
# File lib/hershey/word.rb, line 5
def initialize(text, options = {})
  @spacing = 0

  @characters = text.each_char.map do |c|
    char = Character.new(c, options)
    @spacing += char.spacing

    char
  end
end

Public Instance Methods

spacing() click to toggle source
# File lib/hershey/word.rb, line 16
def spacing
  @spacing ||= @characters.inject(0) {|memo, c| memo + c.spacing}
end
to_path(current_offset) click to toggle source
# File lib/hershey/word.rb, line 20
def to_path(current_offset)
  offset = 0
  letters = []
  @characters.each do |c|
    letters << c.to_path(offset)
    offset += c.spacing
  end

  %Q{<g transform="translate(#{current_offset},0)">#{letters.join}</g>}
end