Class: Octicons::Octicon

Inherits:
Object
  • Object
show all
Defined in:
lib/octicons/octicon.rb

Constant Summary collapse

DEFAULT_HEIGHT =
16

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options = {})
  @symbol = symbol.to_s
  if octicon = get_octicon(@symbol, options)
    @path = octicon["path"]
    @width = octicon["width"]
    @height = octicon["height"]
    @keywords = octicon["keywords"]
    @options = 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

#heightObject (readonly)

Returns the value of attribute height.



7
8
9
# File 'lib/octicons/octicon.rb', line 7

def height
  @height
end

#keywordsObject (readonly)

Returns the value of attribute keywords.



7
8
9
# File 'lib/octicons/octicon.rb', line 7

def keywords
  @keywords
end

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/octicons/octicon.rb', line 7

def options
  @options
end

#pathObject (readonly)

Returns the value of attribute path.



7
8
9
# File 'lib/octicons/octicon.rb', line 7

def path
  @path
end

#symbolObject (readonly)

Returns the value of attribute symbol.



7
8
9
# File 'lib/octicons/octicon.rb', line 7

def symbol
  @symbol
end

#widthObject (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_svgObject

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