class Forkforge::CodePoints
Public Class Methods
new(hash)
click to toggle source
# File lib/forkforge/internal/code_point.rb, line 44 def initialize hash @hash = hash end
Public Instance Methods
inspect()
click to toggle source
# File lib/forkforge/internal/code_point.rb, line 64 def inspect @hash.inspect end
method_missing(method, *args) { |code_point v| ... }
click to toggle source
Calls superclass method
# File lib/forkforge/internal/code_point.rb, line 89 def method_missing method, *args, &block m, rest = "#{method}".split '_', 2 if args.count <= 1 && !(result = filter :character_name, /#{m}/i).empty? result.select! { |k, v| v[:character_decomposition_mapping] =~ case args.first when String then /#{args.first.codepoints.map { |cp| '%04X' % cp }.join('|')}\Z/ when Integer then /#{'%04X' % cp}/ when Regexp then args.first else /#{args.first}/ end } if args.count > 0 result.each do |k, v| yield CodePoint.new v end if block_given? && !rest.nil? result = CodePoints.new(result) rest.nil? ? result : result.send(rest.to_sym) else super end rescue => e # Log it! self end
respond_to?(method)
click to toggle source
# File lib/forkforge/internal/code_point.rb, line 84 def respond_to? method m = "#{method}".split '_' return !(filter :character_name, /#{m}/i).empty? end
select(field, pattern = nil)
click to toggle source
# File lib/forkforge/internal/code_point.rb, line 60 def select field, pattern = nil CodePoints.new filter field, pattern end
to_a()
click to toggle source
# File lib/forkforge/internal/code_point.rb, line 68 def to_a @hash.values end
to_h()
click to toggle source
FIXME is is shallow or deep copy?
# File lib/forkforge/internal/code_point.rb, line 73 def to_h @hash.dup end
Also aliased as: to_hash
to_s()
click to toggle source
# File lib/forkforge/internal/code_point.rb, line 78 def to_s @hash.values.map { |v| CodePoint.new(v).to_s }.join end
Private Instance Methods
filter(field, pattern = nil)
click to toggle source
# File lib/forkforge/internal/code_point.rb, line 48 def filter field, pattern = nil pattern = case pattern when NilClass then /\A.+/ # not empty when Regexp then pattern else Regexp.new(pattern) end @hash.select { |k, v| v[field.to_sym] =~ pattern } end