Class: FontAwesome5Rails::Parsers::FaIconParser
- Inherits:
-
Object
- Object
- FontAwesome5Rails::Parsers::FaIconParser
- Includes:
- ActionView::Helpers::TagHelper, ParseMethods
- Defined in:
- lib/font_awesome5_rails/parsers/fa_icon_parser.rb
Constant Summary collapse
- GEM_PATH =
Pathname.new('../../../../').(__FILE__)
Instance Attribute Summary collapse
-
#attrs ⇒ Object
readonly
Returns the value of attribute attrs.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#icon ⇒ Object
readonly
Returns the value of attribute icon.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#right ⇒ Object
readonly
Returns the value of attribute right.
-
#style ⇒ Object
readonly
Returns the value of attribute style.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #classes ⇒ Object
- #file ⇒ Object
-
#initialize(icon, options) ⇒ FaIconParser
constructor
A new instance of FaIconParser.
- #sizes ⇒ Object
- #tag ⇒ Object
Methods included from ParseMethods
#arr_with_fa, #icon_type, #icon_type_path, #prepend_fa
Constructor Details
#initialize(icon, options) ⇒ FaIconParser
Returns a new instance of FaIconParser.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/font_awesome5_rails/parsers/fa_icon_parser.rb', line 13 def initialize(icon, ) @icon = icon @options = @data = [:data] @style = [:style] @text = [:text] @title = [:title] @right = [:right] == true @attrs = .except(:text, :type, :class, :icon, :animation, :size, :right) end |
Instance Attribute Details
#attrs ⇒ Object (readonly)
Returns the value of attribute attrs.
11 12 13 |
# File 'lib/font_awesome5_rails/parsers/fa_icon_parser.rb', line 11 def attrs @attrs end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
11 12 13 |
# File 'lib/font_awesome5_rails/parsers/fa_icon_parser.rb', line 11 def data @data end |
#icon ⇒ Object (readonly)
Returns the value of attribute icon.
11 12 13 |
# File 'lib/font_awesome5_rails/parsers/fa_icon_parser.rb', line 11 def icon @icon end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
11 12 13 |
# File 'lib/font_awesome5_rails/parsers/fa_icon_parser.rb', line 11 def @options end |
#right ⇒ Object (readonly)
Returns the value of attribute right.
11 12 13 |
# File 'lib/font_awesome5_rails/parsers/fa_icon_parser.rb', line 11 def right @right end |
#style ⇒ Object (readonly)
Returns the value of attribute style.
11 12 13 |
# File 'lib/font_awesome5_rails/parsers/fa_icon_parser.rb', line 11 def style @style end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
11 12 13 |
# File 'lib/font_awesome5_rails/parsers/fa_icon_parser.rb', line 11 def text @text end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
11 12 13 |
# File 'lib/font_awesome5_rails/parsers/fa_icon_parser.rb', line 11 def title @title end |
Instance Method Details
#classes ⇒ Object
24 25 26 |
# File 'lib/font_awesome5_rails/parsers/fa_icon_parser.rb', line 24 def classes @classes ||= parse_classes end |
#file ⇒ Object
38 39 40 41 |
# File 'lib/font_awesome5_rails/parsers/fa_icon_parser.rb', line 38 def file file = GEM_PATH.join("app/assets/images/fa5/#{icon_type_path(@options[:type])}/#{@icon}.svg") file.exist? ? file : nil end |
#sizes ⇒ Object
28 29 30 |
# File 'lib/font_awesome5_rails/parsers/fa_icon_parser.rb', line 28 def sizes @sizes ||= @options[:size].nil? ? '' : arr_with_fa(@options[:size]).uniq.join(' ').strip end |
#tag ⇒ Object
32 33 34 35 36 |
# File 'lib/font_awesome5_rails/parsers/fa_icon_parser.rb', line 32 def tag return icon_content_tag if @text.nil? @right ? (text_content_tag + icon_content_tag) : (icon_content_tag + text_content_tag) end |