module Prawn::Markup::Processor::Inputs

Constants

DEFAULT_CHECKABLE_CHARS

Public Class Methods

prepended(base) click to toggle source
# File lib/prawn/markup/processor/inputs.rb, line 18
def self.prepended(base)
  base.known_elements.push('input')
end

Public Instance Methods

start_input() click to toggle source
# File lib/prawn/markup/processor/inputs.rb, line 22
def start_input
  type = current_attrs['type'].to_sym
  if DEFAULT_CHECKABLE_CHARS.keys.include?(type)
    append_checked_symbol(type)
  end
end

Private Instance Methods

append_checked_symbol(type) click to toggle source
# File lib/prawn/markup/processor/inputs.rb, line 31
def append_checked_symbol(type)
  char = checkable_symbol(type)
  append_text(build_font_tag(char))
end
build_font_tag(content) click to toggle source
# File lib/prawn/markup/processor/inputs.rb, line 48
def build_font_tag(content)
  return content if symbol_font_options.empty?

  out = +'<font'
  symbol_font_options.each do |key, value|
    out << " #{key}=\"#{value}\""
  end
  out << '>'
  out << content
  out << '</font>'
end
checkable_symbol(type) click to toggle source
# File lib/prawn/markup/processor/inputs.rb, line 36
def checkable_symbol(type)
  state = current_attrs.key?('checked') ? :checked : :unchecked
  dig_options(:input, type, state) || DEFAULT_CHECKABLE_CHARS[type][state]
end
symbol_font_options() click to toggle source
# File lib/prawn/markup/processor/inputs.rb, line 41
def symbol_font_options
  @symbol_font_options ||= {
    name: dig_options(:input, :symbol_font),
    size: dig_options(:input, :symbol_font_size)
  }.compact
end