module Rabbit::Format::SpanTextFormatter

Constants

PANGO2CSS

Attributes

value[R]

Public Class Methods

new(value) click to toggle source
# File lib/rabbit/formatter.rb, line 45
def initialize(value)
  @value = value
end

Public Instance Methods

format(text) click to toggle source
# File lib/rabbit/formatter.rb, line 57
def format(text)
  tagged_text(text, "span", normalize_attribute(name, @value))
end
html_format(text) click to toggle source
# File lib/rabbit/formatter.rb, line 61
def html_format(text)
  css_name, css_value = pango2css(name, @value)
  tagged_text(text, "span", {'style' => "#{css_name}: #{css_value};"})
end
html_formatter?() click to toggle source
# File lib/rabbit/formatter.rb, line 53
def html_formatter?
  true
end
text_formatter?() click to toggle source
# File lib/rabbit/formatter.rb, line 49
def text_formatter?
  true
end

Private Instance Methods

normalize_attribute(name, value) click to toggle source
# File lib/rabbit/formatter.rb, line 67
def normalize_attribute(name, value)
  {name => value}
end
pango2css(name, value) click to toggle source
# File lib/rabbit/formatter.rb, line 71
def pango2css(name, value)
  css_name = PANGO2CSS[name]
  if css_name.respond_to?(:call)
    css_name.call(name, value)
  else
    [css_name || name, value]
  end
end