Class: Jekyll::FontAwesome::Svg::FontAwesomeIcon
- Inherits:
-
Object
- Object
- Jekyll::FontAwesome::Svg::FontAwesomeIcon
- Defined in:
- lib/jekyll/fontawesome/svg/fa-icon.rb
Instance Method Summary collapse
-
#initialize(icon) ⇒ FontAwesomeIcon
constructor
A new instance of FontAwesomeIcon.
- #mapper(type) ⇒ Object
-
#to_filename ⇒ Object
absolute path to file.
-
#to_folder_name ⇒ Object
solid / brands / regular.
-
#to_font_awesome_type ⇒ Object
fab / far / fas.
-
#to_icon_name ⇒ Object
fa-dev.
- #to_svg_html ⇒ Object
- #value ⇒ Object
Constructor Details
#initialize(icon) ⇒ FontAwesomeIcon
Returns a new instance of FontAwesomeIcon.
5 6 7 |
# File 'lib/jekyll/fontawesome/svg/fa-icon.rb', line 5 def initialize(icon) @icon = icon end |
Instance Method Details
#mapper(type) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/jekyll/fontawesome/svg/fa-icon.rb', line 9 def mapper(type) { "fas" => "solid", "fab" => "brands", "far" => "regular" }[type] end |
#to_filename ⇒ Object
absolute path to file
35 36 37 38 |
# File 'lib/jekyll/fontawesome/svg/fa-icon.rb', line 35 def to_filename base_directory = __dir__ + "/assets/fa_svgs/" base_directory + to_folder_name + "/" + to_icon_name + ".svg" end |
#to_folder_name ⇒ Object
solid / brands / regular
25 26 27 |
# File 'lib/jekyll/fontawesome/svg/fa-icon.rb', line 25 def to_folder_name mapper(to_font_awesome_type) end |
#to_font_awesome_type ⇒ Object
fab / far / fas
30 31 32 |
# File 'lib/jekyll/fontawesome/svg/fa-icon.rb', line 30 def to_font_awesome_type @icon.split('.').first.strip end |
#to_icon_name ⇒ Object
fa-dev
18 19 20 21 22 |
# File 'lib/jekyll/fontawesome/svg/fa-icon.rb', line 18 def to_icon_name icon = @icon.split('.').last.split('-') icon.shift icon.join('-') end |
#to_svg_html ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/jekyll/fontawesome/svg/fa-icon.rb', line 40 def to_svg_html file = File.read(to_filename) path_data = /^.*path d="(.*)" ?\/>.*$/.match(file).captures.first viewBox = /^.*viewBox="([^"]*)".*$/.match(file).captures.first "<symbol id='#{@icon}' viewBox='#{viewBox}'> <title>#{to_icon_name}</title> <path class='path1' d='#{path_data}'></path> </symbol> " end |
#value ⇒ Object
51 52 53 |
# File 'lib/jekyll/fontawesome/svg/fa-icon.rb', line 51 def value @icon end |