Class: Octicons::Octicon
- Inherits:
-
Object
- Object
- Octicons::Octicon
- Defined in:
- lib/octicons/octicon.rb
Constant Summary collapse
- DEFAULT_HEIGHT =
16
Instance Attribute Summary collapse
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#keywords ⇒ Object
readonly
Returns the value of attribute keywords.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#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 = {}) ⇒ Octicon
constructor
A new instance of Octicon.
-
#to_svg ⇒ Object
Returns an string representing a <svg> tag.
Constructor Details
#initialize(symbol, options = {}) ⇒ Octicon
Returns a new instance of Octicon.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/octicons/octicon.rb', line 9 def initialize(symbol, = {}) @symbol = symbol.to_s if octicon = get_octicon(@symbol, ) @path = octicon["path"] @width = octicon["width"] @height = octicon["height"] @keywords = octicon["keywords"] @options = .dup @options.merge!({ class: classes, viewBox: viewbox, version: "1.1" }) @options.merge!(size) @options.merge!(a11y) else raise "Couldn't find octicon symbol for #{@symbol.inspect}" end end |
Instance Attribute Details
#height ⇒ Object (readonly)
Returns the value of attribute height.
7 8 9 |
# File 'lib/octicons/octicon.rb', line 7 def height @height end |
#keywords ⇒ Object (readonly)
Returns the value of attribute keywords.
7 8 9 |
# File 'lib/octicons/octicon.rb', line 7 def keywords @keywords end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/octicons/octicon.rb', line 7 def @options end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
7 8 9 |
# File 'lib/octicons/octicon.rb', line 7 def path @path end |
#symbol ⇒ Object (readonly)
Returns the value of attribute symbol.
7 8 9 |
# File 'lib/octicons/octicon.rb', line 7 def symbol @symbol end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
7 8 9 |
# File 'lib/octicons/octicon.rb', line 7 def width @width end |
Instance Method Details
#to_svg ⇒ Object
Returns an string representing a <svg> tag
30 31 32 |
# File 'lib/octicons/octicon.rb', line 30 def to_svg "<svg #{html_attributes}>#{@path}</svg>" end |