Module: Prawn::Icon::Interface
- Defined in:
- lib/prawn/icon.rb
Instance Method Summary collapse
-
#icon(key, opts = {}) ⇒ Object
Set up and draw an icon on this document.
-
#inline_icon(text, opts = {}) ⇒ Object
Initialize a new formatted text box containing icon information, but don’t render it to the document.
-
#make_icon(key, opts = {}) ⇒ Object
Initialize a new icon object, but do not render it to the document.
Instance Method Details
#icon(key, opts = {}) ⇒ Object
Set up and draw an icon on this document. This method operates much like Prawn::Text::Box.
Parameters:
- key
-
Contains the key to a particular icon within a font family. If :inline_format is true, then key may contain formatted text marked with <icon></icon> tags and any tag supported by Prawn’s parser.
- opts
-
A hash of options that may be supplied to the underlying
textmethod call.
Examples:
pdf.icon 'fa-beer'
pdf.icon '<icon color="0099FF">fa-arrows</icon>',
inline_format: true
78 79 80 81 82 |
# File 'lib/prawn/icon.rb', line 78 def icon(key, opts = {}) i = make_icon(key, opts) i.render i end |
#inline_icon(text, opts = {}) ⇒ Object
Initialize a new formatted text box containing icon information, but don’t render it to the document.
Parameters:
- text
-
Input text to be parsed initially for <icon> tags, then passed to Prawn’s formatted text parser.
- opts
-
A hash of options that may be supplied to the underlying text call.
121 122 123 124 125 126 |
# File 'lib/prawn/icon.rb', line 121 def inline_icon(text, opts = {}) parsed = Icon::Parser.format(self, text) content = Text::Formatted::Parser.format(parsed) opts.merge!(inline_format: true, document: self) Text::Formatted::Box.new(content, opts) end |
#make_icon(key, opts = {}) ⇒ Object
Initialize a new icon object, but do not render it to the document.
Parameters:
- key
-
Contains the key to a particular icon within a font family. If :inline_format is true, then key may contain formatted text marked with <icon></icon> tags and any tag supported by Prawn’s parser.
- opts
-
A hash of options that may be supplied to the underlying text method call.
99 100 101 102 103 104 105 |
# File 'lib/prawn/icon.rb', line 99 def make_icon(key, opts = {}) if opts[:inline_format] inline_icon(key, opts) else Icon.new(key, self, opts) end end |