8000 GitHub - yhzgirl/wordsource: exercise
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

yhzgirl/wordsource

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

To Do

  1. Add callbacks
  2. Add Twitter API
  3. Refactor tests once mock/double/stub learned for rspec

Background

A WordSource is a source of words. You can get words from it by calling the next_word method.

It keeps analytical information of each word that it has seen.

Example

There are several potential sources for the words. In this example we assume that the word source has been initialised with the following string: "lorem,ipsum,ipsum"

   src = LoremIpsumWordSource.new
   src.next_word
     # => "lorem"
   src.next_word
     # => "ipsum"
   src.next_word
     # => "ipsum"
   src.top_5_words
     # => ["ipsum","lorem",nil,nil,nil]
   src.top_5_consonants
     # => ["m","p","s","l","r"]
   src.count
     # => 3 # total words seen

Run method

   src = LoremIpsumWordSource.new
   # This will run until there are no more words for the source implementation.
   src.run
     # => true

Assignment

  1. Implement LoremIpsumWordSource that pulls in words from "lorem_ipsum.txt"; include the methods described above
  2. Add callbacks on specific words e.g. every time "semper" is encountered, call those callbacks registered for "semper"
  3. implement a WordSource that uses the twitter API (instead of loading words from a file)

About

exercise

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0