Class: FontAwesome::Icon

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Icon

Returns a new instance of Icon.



6
7
8
9
10
# File 'lib/font_awesome/icon.rb', line 6

def initialize(name)
  @hex_code = HexCode.new(name)
  @font = Font.instance
  @style = default_style
end

Instance Attribute Details

#fontObject (readonly)

Returns the value of attribute font.



4
5
6
# File 'lib/font_awesome/icon.rb', line 4

def font
  @font
end

#hex_codeObject (readonly)

Returns the value of attribute hex_code.



4
5
6
# File 'lib/font_awesome/icon.rb', line 4

def hex_code
  @hex_code
end

#styleObject

Returns the value of attribute style.



3
4
5
# File 'lib/font_awesome/icon.rb', line 3

def style
  @style
end

Class Method Details

.allObject



26
27
28
# File 'lib/font_awesome/icon.rb', line 26

def self.all
  HexCode.all.map {|name, code| new name }
end

Instance Method Details

#nameObject



12
13
14
# File 'lib/font_awesome/icon.rb', line 12

def name
  hex_code.name
end

#to_svgObject



16
17
18
19
20
# File 'lib/font_awesome/icon.rb', line 16

def to_svg
  Nokogiri::XML::Builder.new do |xml|
    build_svg(xml)
  end.to_xml(save_with: Nokogiri::XML::Node::SaveOptions::AS_XML | Nokogiri::XML::Node::SaveOptions::NO_DECLARATION).strip
end

#to_uriObject



22
23
24
# File 'lib/font_awesome/icon.rb', line 22

def to_uri
  "data:image/svg+xml,#{URI.escape(to_svg)}"
end