class Entypo::Charmap

The Charmap simply “parses” a CSS file which must conform to the following format:

.icon$NAME$:before { content: …} /* $codepoint$ */

Constants

Icon

Attributes

icons[R]

Access the icons array.

Public Class Methods

icons() click to toggle source

Public: Returns Array of icons.

Returns Array of Icon instances.

# File lib/entypo/charmap.rb, line 25
def self.icons
  instance.icons
end
instance() click to toggle source

Public: Access the shared instance based on our default entypo.scss file.

Returns Charmap instance.

# File lib/entypo/charmap.rb, line 18
def self.instance
  @@instance ||= self.new File.expand_path('../../../app/assets/stylesheets/entypo.scss.erb', __FILE__)
end
new(path) click to toggle source
# File lib/entypo/charmap.rb, line 32
def initialize(path)
  @icons = load(path)
end

Private Instance Methods

load(path) click to toggle source
# File lib/entypo/charmap.rb, line 38
def load(path)
  ERB.new(File.read(path)).result.split("\n").map do |line|
    if line =~ %r{\A\.(#{Entypo.css_prefix}-[a-z0-9\-]+):before.*/\* ([0-9a-f]+)}
      Icon.new($1, $2)
    end
  end.compact.sort
end