Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/highscore/string.rb

Overview

monkey patch to call custom methods on arbitrary strings

Instance Method Summary collapse

Instance Method Details

#consonantsObject

get all consonants from a string

Returns:

  • String



34
35
36
# File 'lib/highscore/string.rb', line 34

def consonants
  gsub(/[aeiou]/, '')
end

#keywords(wordlist = nil, &block) ⇒ Object

get keywords from the string

Parameters:

  • wordlist (defaults to: nil)

    Highscore::Wordlist

  • block

    Block

Returns:

  • Highscore::Keywords



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/highscore/string.rb', line 12

def keywords(wordlist = nil, &block)
  content = Highscore::Content.new(self, wordlist)

  if block_given?
    content.configure do
      content.instance_eval(&block)
    end
  end

  content.keywords
end

#vowelsObject

get all vowels from a string

Returns:

  • String



27
28
29
# File 'lib/highscore/string.rb', line 27

def vowels
  gsub(/[^aeiou]/, '')
end