class Rabbit::Element::FontAwesomeText
Public Class Methods
Source
# File lib/rabbit/element/text.rb, line 66 def initialize(*args) super(*args) @character = self.class[@text] raise UnknownFontAwesomeNameError.new(@text) if @character.nil? end
Calls superclass method
Rabbit::Element::TextElement::new
Private Class Methods
Source
# File lib/rabbit/element/text.rb, line 60 def css_path ENV["RABBIT_FONT_AWESOME_CSS"] || "/usr/share/fonts-font-awesome/css/font-awesome.css" # Debian end
Source
# File lib/rabbit/element/text.rb, line 37 def mapping @mapping ||= File.open(css_path) do |css| mapping = {} names = [] css.each_line do |line| case line when /\A\.fa-(.+?):before/ names << Regexp.last_match[1] when /\A\s*content:\s*\"\\(.+?)\"/ code_point = Integer(Regexp.last_match[1], 16) character = [code_point].pack("U") names.each do |name| mapping[name] = character end names.clear when /\A}/ names.clear end end mapping end end
Public Instance Methods
Source
# File lib/rabbit/element/text.rb, line 72 def markuped_text "<span font_family=\"FontAwesome\">#{@character}</span>" end