Class: Basicons::Basicon
- Inherits:
-
Object
- Object
- Basicons::Basicon
- Defined in:
- lib/basicons/basicon.rb
Constant Summary collapse
- SVG_SIZES =
{ small: 16, medium: 32, large: 64 }.freeze
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#symbol ⇒ Object
readonly
Returns the value of attribute symbol.
Instance Method Summary collapse
-
#initialize(symbol, options = {}) ⇒ Basicon
constructor
A new instance of Basicon.
- #to_svg ⇒ Object
Constructor Details
#initialize(symbol, options = {}) ⇒ Basicon
Returns a new instance of Basicon.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/basicons/basicon.rb', line 12 def initialize(symbol, = {}) @symbol = symbol.to_s @options = .dup if @data = Basicons::SVG_DATA[@symbol] @options.merge!({ class: classes, width: svg_size, height: svg_size, viewBox: '0 0 24 24', stroke: 'currentColor', fill: 'none' }) @options.delete(:size) @options['stroke-width'] = 2 @options['stroke-linecap'] = 'round' @options['stroke-linejoin'] = 'round' @options['xmlns'] = 'http://www.w3.org/2000/svg' else raise "<#{@symbol}> not found" end end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
9 10 11 |
# File 'lib/basicons/basicon.rb', line 9 def data @data end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/basicons/basicon.rb', line 10 def @options end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
9 10 11 |
# File 'lib/basicons/basicon.rb', line 9 def size @size end |
#symbol ⇒ Object (readonly)
Returns the value of attribute symbol.
10 11 12 |
# File 'lib/basicons/basicon.rb', line 10 def symbol @symbol end |
Instance Method Details
#to_svg ⇒ Object
36 37 38 |
# File 'lib/basicons/basicon.rb', line 36 def to_svg "<svg #{html_attributes}>#{@data}</svg>" end |