Class: Prawn::Emoji::Text

Inherits:
Object
  • Object
show all
Defined in:
lib/prawn/emoji/text.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ Text

Returns a new instance of Text.



10
11
12
13
# File 'lib/prawn/emoji/text.rb', line 10

def initialize(text)
  @left, emoji_char, @remaining = partition_by_emoji(text)
  @emoji = Emoji::Unicode.new(emoji_char) unless emoji_char.empty?
end

Instance Attribute Details

#emojiObject (readonly)

Returns the value of attribute emoji.



8
9
10
# File 'lib/prawn/emoji/text.rb', line 8

def emoji
  @emoji
end

#leftObject (readonly)

Returns the value of attribute left.



8
9
10
# File 'lib/prawn/emoji/text.rb', line 8

def left
  @left
end

#remainingObject (readonly)

Returns the value of attribute remaining.



8
9
10
# File 'lib/prawn/emoji/text.rb', line 8

def remaining
  @remaining
end

Instance Method Details

#contains_emoji?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/prawn/emoji/text.rb', line 15

def contains_emoji?
  !emoji.nil?
end

#left_with_emojiObject



19
20
21
# File 'lib/prawn/emoji/text.rb', line 19

def left_with_emoji
  left + emoji.to_s
end

#to_sObject



23
24
25
# File 'lib/prawn/emoji/text.rb', line 23

def to_s
  left_with_emoji + remaining
end