Class: PhosphorIcons::Icon
- Inherits:
-
Object
- Object
- PhosphorIcons::Icon
- Defined in:
- lib/phosphor_icons/icon.rb
Constant Summary collapse
- DEFAULT_STYLE =
"regular"
- SUPPORTED_STYLES =
[DEFAULT_STYLE, "bold", "light", "duotone", "fill", "thin"]
- NATURAL_HEIGHTS =
[16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80]
- DEFAULT_HEIGHT =
24
Instance Attribute Summary collapse
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#style ⇒ Object
readonly
Returns the value of attribute style.
-
#symbol ⇒ Object
readonly
Returns the value of attribute symbol.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
-
#initialize(symbol, options = {}) ⇒ Icon
constructor
A new instance of Icon.
- #to_s ⇒ Object
- #to_svg ⇒ Object
Constructor Details
#initialize(symbol, options = {}) ⇒ Icon
Returns a new instance of Icon.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/phosphor_icons/icon.rb', line 12 def initialize(symbol, = {}) @symbol = symbol.to_s @style = [:style] || DEFAULT_STYLE if (phosphor_icon = get_phosphor_icon(@symbol, )) @path = phosphor_icon["path"] @width = phosphor_icon["width"] @height = phosphor_icon["height"] @options = { class: "phosphor-icon #{[:class]}".strip, viewBox: viewbox, xmlns: "http://www.w3.org/2000/svg", fill: "currentColor", width: @width, height: @height, } else raise IconNotFoundError, "Couldn't find #{self}" end end |
Instance Attribute Details
#height ⇒ Object (readonly)
Returns the value of attribute height.
10 11 12 |
# File 'lib/phosphor_icons/icon.rb', line 10 def height @height end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/phosphor_icons/icon.rb', line 10 def @options end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
10 11 12 |
# File 'lib/phosphor_icons/icon.rb', line 10 def path @path end |
#style ⇒ Object (readonly)
Returns the value of attribute style.
10 11 12 |
# File 'lib/phosphor_icons/icon.rb', line 10 def style @style end |
#symbol ⇒ Object (readonly)
Returns the value of attribute symbol.
10 11 12 |
# File 'lib/phosphor_icons/icon.rb', line 10 def symbol @symbol end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
10 11 12 |
# File 'lib/phosphor_icons/icon.rb', line 10 def width @width end |
Instance Method Details
#to_s ⇒ Object
36 37 38 |
# File 'lib/phosphor_icons/icon.rb', line 36 def to_s "Phosphor Icon for #{symbol.inspect} with style #{style.inspect}" end |
#to_svg ⇒ Object
32 33 34 |
# File 'lib/phosphor_icons/icon.rb', line 32 def to_svg "<svg #{html_attributes}>#{path}</svg>" end |