Class: Crypticons::Crypticon

Inherits:
Object
  • Object
show all
Defined in:
lib/crypticons/crypticon.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(symbol, options = {}) ⇒ Crypticon

Returns a new instance of Crypticon.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/crypticons/crypticon.rb', line 6

def initialize(symbol, options = {})
  @symbol = symbol.to_s
  if crypticon = Crypticons::CRYPTICON_SYMBOLS[@symbol]

    @path = crypticon["path"]
    @width = crypticon["width"].to_i
    @height = crypticon["height"].to_i

    @keywords = crypticon["keywords"]

    @options = options
    @options.merge!({
      class:   classes,
      viewBox: viewbox,
      version: "1.1"
    })
    @options.merge!(size)
    @options.merge!(a11y)
  else
    raise "Couldn't find crypticon symbol for #{@symbol.inspect}"
  end
end

Instance Attribute Details

#heightObject (readonly)

Returns the value of attribute height.



4
5
6
# File 'lib/crypticons/crypticon.rb', line 4

def height
  @height
end

#keywordsObject (readonly)

Returns the value of attribute keywords.



4
5
6
# File 'lib/crypticons/crypticon.rb', line 4

def keywords
  @keywords
end

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/crypticons/crypticon.rb', line 4

def options
  @options
end

#pathObject (readonly)

Returns the value of attribute path.



4
5
6
# File 'lib/crypticons/crypticon.rb', line 4

def path
  @path
end

#symbolObject (readonly)

Returns the value of attribute symbol.



4
5
6
# File 'lib/crypticons/crypticon.rb', line 4

def symbol
  @symbol
end

#widthObject (readonly)

Returns the value of attribute width.



4
5
6
# File 'lib/crypticons/crypticon.rb', line 4

def width
  @width
end

Instance Method Details

#to_svgObject

Returns an string representing a <svg> tag



30
31
32
# File 'lib/crypticons/crypticon.rb', line 30

def to_svg
  "<svg #{html_attributes}>#{@path}</svg>"
end