Sha256: 7bb865fffe87627627aa5062091d438262afeb650712585c4443af1c33ed0bcf
Contents?: true
Size: 1.25 KB
Versions: 2
Compression:
Stored size: 1.25 KB
Contents
# encoding: utf-8 require 'forkforge/unicode' module Forkforge module Selector def self.included base re, basename = nil, base.name.gsub(/.*::/, '') # FILTER = { 'Tagged' => /^<.*?>$/ } if base.const_defined?(:FILTER) filter = base.const_get(:FILTER).to_a.flatten re = filter.last basename = basename.gsub(/^#{filter.first}/, '') end basename = (Forkforge::Unicode::camel_to_underscore basename).to_sym # HASH = Forkforge::UnicodeData::all_character_name /^<.*?>$/ base.const_set :HASH, UnicodeData::send("all_#{basename}", re) # ALL = Forkforge::UnicodeData::all_bidirectional_category.uniq base.const_set :ALL, base::HASH.map { |k, v| v[basename] }.uniq base.class_eval %Q{ CHARACTERS = HASH.reduce({}) { |memo, v| (memo[v.last[:#{basename}]] ||= []) << v.last memo } } base.extend base end end module TaggedCharacterName FILTER = { 'Tagged' => /^<.*?>$/ } include Selector # E. g. def control ⇒ [ ALL_ITEMS_WITH_CONTROL_NAME ] CHARACTERS.each { |k, v| define_method(k.downcase.gsub(/^<|>$/, '').gsub(/\W/, '_')) { v } } end module BidirectionalCategory include Selector end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
forkforge-0.0.4 | lib/forkforge/selector.rb |
forkforge-0.0.3 | lib/forkforge/selector.rb |