Class: FA::Icon

Inherits:
Base
  • Object
show all
Defined in:
lib/fa/icon.rb

Overview

FontAwesome 5 (Pro) Helper for generating icons

Since:

  • 0.1.0

Constant Summary

Constants inherited from Base

Base::MODES, Base::STYLES

Instance Method Summary collapse

Methods inherited from Base

p, #safe

Constructor Details

#initialize(fa, options = {}) ⇒ Icon

Creates a new Icon instance

Parameters:

  • fa (Hash)

    The complete icon configuration

  • fa (String)

    The icon name to generate

  • options (Hash) (defaults to: {})

    Additional configuration options

Since:

  • 0.1.0



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/fa/icon.rb', line 11

def initialize(fa, options = {})
  @options = options
  if fa.is_a?(Hash)
    @name = fa[:name]
    @options = fa[:options]
  elsif fa.is_a?(String) || fa.is_a?(Symbol)
    @name = fa.to_s
  else
    raise ArgumentError, 'Unexpected argument type.'
  end
end

Instance Method Details

#rawObject

Outputs the formatted icon directly.

Since:

  • 0.1.0



24
25
26
# File 'lib/fa/icon.rb', line 24

def raw
  parse_icon(@name, @options)
end