Sha256: ada9442d08b008622af6bb94594721ba6a8491ab9575474d051f713c8c25a6d1

Contents?: true

Size: 821 Bytes

Versions: 1

Compression:

Stored size: 821 Bytes

Contents

module StringDirection
  # Methods intended to be monkey patched to String through `String.include(StringDirection::StringMethods)`. This will allow stuff like `'English'.direction #=> 'ltr'`. All methods are delegated to {Detector} with `self` as string argument.
  module StringMethods
    # @see Detector#direction
    # @return [String]
    def direction
      string_direction_detector.direction(self)
    end

    # @see Detector#ltr?
    def ltr?
      string_direction_detector.ltr?(self)
    end

    # @see Detector#rtl?
    def rtl?
      string_direction_detector.rtl?(self)
    end

    # @see Detector#bidi?
    def bidi?
      string_direction_detector.bidi?(self)
    end

    private

    def string_direction_detector
      @string_direction_detector ||= StringDirection::Detector.new
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
string-direction-1.0.0 lib/string-direction/string_methods.rb