Module: Prawn::Rtl::Connector

Defined in:
lib/prawn/rtl/connector.rb,
lib/prawn/rtl/connector/logic.rb

Defined Under Namespace

Modules: Logic

Class Method Summary collapse

Class Method Details

.connect(string) ⇒ Object



9
10
11
# File 'lib/prawn/rtl/connector.rb', line 9

def self.connect(string)
  Prawn::Rtl::Connector::Logic.transform(string)
end

.fix_rtl(string) ⇒ Object



13
14
15
16
# File 'lib/prawn/rtl/connector.rb', line 13

def self.fix_rtl(string)
  return string unless include_rtl?(string)
  reorder(connect(string))
end

.include_rtl?(string) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
28
29
30
# File 'lib/prawn/rtl/connector.rb', line 25

def self.include_rtl?(string)
  TwitterCldr::Shared::Bidi
    .from_string(string)
    .types
    .include?(:R)
end

.reorder(string) ⇒ Object



18
19
20
21
22
23
# File 'lib/prawn/rtl/connector.rb', line 18

def self.reorder(string)
  TwitterCldr::Shared::Bidi
    .from_string(string, direction: :RTL)
    .reorder_visually!
    .to_s
end