Sha256: 131d158c6a2fe7b9d1f88a96cc810de9bdbc965d00cdb012bff1f76f9ee226c5

Contents?: true

Size: 544 Bytes

Versions: 2

Compression:

Stored size: 544 Bytes

Contents

module WordCountAnalyzer
  class HyphenatedWord
    # Rubular: http://rubular.com/r/RjZ7qi0uFf
    DASHED_LINE_REGEX = /\s-{2,}(\s|$)|\A-{2,}(\s|$)/

    attr_reader :token
    def initialize(token:)
      @token = token.gsub(DASHED_LINE_REGEX, '')
    end

    def hyphenated_word?
      (token.include?('-') || token.include?('﹘')) && !WordCountAnalyzer::Hyperlink.new.hyperlink?(token)
    end

    def count_as_multiple
      token.split(/[﹘,-]/).length
    end

    def replace
      token.split(/[﹘,-]/).join(' ')
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
word_count_analyzer-1.0.1 lib/word_count_analyzer/hyphenated_word.rb
word_count_analyzer-1.0.0 lib/word_count_analyzer/hyphenated_word.rb