-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change app from procedural to class and method based
- Loading branch information
Showing
6 changed files
with
80 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--color | ||
--format progress |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
file = File.new('../models/bookmark_url.lst', 'r') | ||
file.close | ||
|
||
File.open('../models/bookmark_url.lst', 'r') do |file| | ||
contentsArray = [] | ||
while line = file.gets | ||
# puts "** " + line.chomp + " **" | ||
contentsArray.push line | ||
end | ||
|
||
#f = File.open('bookmark_url.lst', 'r') do |file| | ||
#File.each_line (|line| puts line) | ||
# contentsArray = [] | ||
# f.each_line {|line| | ||
# contentArray.push line | ||
# } | ||
|
||
puts contentsArray[rand(contentsArray.length)] | ||
|
||
end | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
class Randomizer | ||
|
||
def initialize(name) | ||
@name = name | ||
end | ||
|
||
def generate() | ||
File.open("#{@name}", 'r') do |file| | ||
@contentsArray = [] | ||
while line = file.gets | ||
@contentsArray.push line | ||
end | ||
end | ||
end | ||
|
||
def display() | ||
puts @contentsArray[rand(@contentsArray.length)] | ||
end | ||
end | ||
|
||
url = Randomizer.new("../app/models/bookmark_url.lst") | ||
url.generate | ||
url.display | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require "spec_helper" | ||
require "randomizer" | ||
|
||
describe "A Randomizer" do | ||
# Your examples go here | ||
it "is named bookmark" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# This file was generated by the `rspec --init` command. Conventionally, all | ||
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. | ||
# Require this file using `require "spec_helper"` to ensure that it is only | ||
# loaded once. | ||
# | ||
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration | ||
RSpec.configure do |config| | ||
config.treat_symbols_as_metadata_keys_with_true_values = true | ||
config.run_all_when_everything_filtered = true | ||
config.filter_run :focus | ||
|
||
# Run specs in random order to surface order dependencies. If you find an | ||
# order dependency and want to debug it, you can fix the order by providing | ||
# the seed, which is printed after each run. | ||
# --seed 1234 | ||
config.order = 'random' | ||
end |