Sha256: 51510c64597a3f46bbaf41ba8dd1fe168e45851186065e599fdf32515b03c2f2

Contents?: true

Size: 552 Bytes

Versions: 14

Compression:

Stored size: 552 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(string: token).hyperlink?
    end

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

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

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
word_count_analyzer-0.0.14 lib/word_count_analyzer/hyphenated_word.rb
word_count_analyzer-0.0.13 lib/word_count_analyzer/hyphenated_word.rb
word_count_analyzer-0.0.12 lib/word_count_analyzer/hyphenated_word.rb
word_count_analyzer-0.0.11 lib/word_count_analyzer/hyphenated_word.rb
word_count_analyzer-0.0.10 lib/word_count_analyzer/hyphenated_word.rb
word_count_analyzer-0.0.9 lib/word_count_analyzer/hyphenated_word.rb
word_count_analyzer-0.0.8 lib/word_count_analyzer/hyphenated_word.rb
word_count_analyzer-0.0.7 lib/word_count_analyzer/hyphenated_word.rb
word_count_analyzer-0.0.6 lib/word_count_analyzer/hyphenated_word.rb
word_count_analyzer-0.0.5 lib/word_count_analyzer/hyphenated_word.rb
word_count_analyzer-0.0.4 lib/word_count_analyzer/hyphenated_word.rb
word_count_analyzer-0.0.3 lib/word_count_analyzer/hyphenated_word.rb
word_count_analyzer-0.0.2 lib/word_count_analyzer/hyphenated_word.rb
word_count_analyzer-0.0.1 lib/word_count_analyzer/hyphenated_word.rb