Sha256: 516f85896b3e79ee35679e2a05b356fd12e8b11fbc92e53b891acc22cfc774da

Contents?: true

Size: 919 Bytes

Versions: 2

Compression:

Stored size: 919 Bytes

Contents

class Sequence
  PATH = File.expand_path("../UTR_51/emoji-sequences.txt".freeze, "lib/emoji/data".freeze)

  def initialize
    @raw_lines = IO.readlines(PATH)
    @_combining_lines = @raw_lines[18..29].map(&:chomp)
    @_flag_lines = @raw_lines[37..293].map(&:chomp)
    @_modifier_lines = @raw_lines[301..620].map(&:chomp)
  end

  def combining_emojis
    @_combining_emojis ||= _combining_lines.map do |line|
      SequenceBase.new(line)
    end
  end

  def flag_emojis
    @_flag_emojis ||= _flag_lines.map do |line|
      SequenceBase.new(line)
    end
  end

  def modifier_emojis
    @_modifier_emojis ||= _modifier_lines.map do |line|
      SequenceBase.new(line)
    end
  end

  def all
    [combining_emojis, flag_emojis, modifier_emojis].flatten(1)
  end

  def as_json
    require "json"
    all.map(&:to_h).to_json
  end

  private

    attr_reader :_combining_lines, :_flag_lines, :_modifier_lines
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
emoji-data-1.0.0 lib/emoji/data/sequence.rb
emoji-data-0.1.0 lib/emoji/data/sequence.rb