Class: DataBase

Inherits:
Object
  • Object
show all
Defined in:
lib/emoji/data/data_base.rb

Constant Summary collapse

DATA_REGEXP =

Format: codepoint(s) ; property=Yes # [count] (character(s)) name

%r{
  (?<codepoints>.+);
  \s{1}
  (?<property>(Emoji_Modifier_Base|Emoji_Presentation|Emoji_Modifier|Emoji))
  \s+
  \#
  \s+
  \[
    (?<count>\d+)
  \]
  \s{1}
  \((?<characters>.+)\)
  \s+
  (?<name>.+)
}x.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw) ⇒ DataBase

Returns a new instance of DataBase.



22
23
24
25
26
27
28
29
30
31
# File 'lib/emoji/data/data_base.rb', line 22

def initialize(raw)
  @raw = raw
  matched = raw.match(DATA_REGEXP)

  @codepoints = matched[:codepoints].rstrip
  @property = matched[:property]
  @count = matched[:count]
  @characters = matched[:characters]
  @name = matched[:name]
end

Instance Attribute Details

#charactersObject (readonly)

Returns the value of attribute characters.



20
21
22
# File 'lib/emoji/data/data_base.rb', line 20

def characters
  @characters
end

#codepointsObject (readonly)

Returns the value of attribute codepoints.



20
21
22
# File 'lib/emoji/data/data_base.rb', line 20

def codepoints
  @codepoints
end

#countObject (readonly)

Returns the value of attribute count.



20
21
22
# File 'lib/emoji/data/data_base.rb', line 20

def count
  @count
end

#nameObject (readonly)

Returns the value of attribute name.



20
21
22
# File 'lib/emoji/data/data_base.rb', line 20

def name
  @name
end

#propertyObject (readonly)

Returns the value of attribute property.



20
21
22
# File 'lib/emoji/data/data_base.rb', line 20

def property
  @property
end

#rawObject (readonly)

Returns the value of attribute raw.



20
21
22
# File 'lib/emoji/data/data_base.rb', line 20

def raw
  @raw
end

Instance Method Details

#to_hObject



33
34
35
36
37
38
39
40
41
# File 'lib/emoji/data/data_base.rb', line 33

def to_h
  Hash(
    codepoints: codepoints,
    property: property,
    count: count,
    characters: characters,
    name: name
  )
end