From 094be4db62c39d32e765bab4723b4257f97f4e47 Mon Sep 17 00:00:00 2001 From: Mitchell Jones <46505941+fussykyloren@users.noreply.github.com> Date: Mon, 11 May 2020 23:05:30 -0500 Subject: [PATCH 1/8] Update README.md --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index d303bdf..6a50290 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,13 @@ # Ruby - Function to Swap Array Elements ## Table of Contents ## Information +This function implements a typical swap function for an array. This is not easily accessible in Ruby (to my knowledge) so I made a function for me but am happy to share it with you! +This function is built with Ruby v2.6.5p114. To check your version, run: +``` +ruby -v +``` ## Status +At this time, the project is __*finished*__. ## Instructions +1. If you do not have ruby installed, follow these [instructions](https://www.ruby-lang.org/en/documentation/installation/). +2. Clone this repository using the following link: From b5626cb1774e8f5e88d9abe20b0073cefbd93176 Mon Sep 17 00:00:00 2001 From: Mitchell Jones <46505941+fussykyloren@users.noreply.github.com> Date: Mon, 11 May 2020 23:10:17 -0500 Subject: [PATCH 2/8] Update README.md --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6a50290..b45a139 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # Ruby - Function to Swap Array Elements ## Table of Contents +- [Information](https://github.com/fussykyloren/ruby-array-swap#information) +- [Status](https://github.com/fussykyloren/ruby-array-swap#status) +- [Instructions](https://github.com/fussykyloren/ruby-array-swap#instructions) ## Information This function implements a typical swap function for an array. This is not easily accessible in Ruby (to my knowledge) so I made a function for me but am happy to share it with you! This function is built with Ruby v2.6.5p114. To check your version, run: @@ -10,4 +13,5 @@ ruby -v At this time, the project is __*finished*__. ## Instructions 1. If you do not have ruby installed, follow these [instructions](https://www.ruby-lang.org/en/documentation/installation/). -2. Clone this repository using the following link: +2. Clone this repository using the following link: https://github.com/fussykyloren/ruby-array-swap.git +3. Use the function as you wish! If you have any suggestions, don't hesitate to raise an issue! From bcf0eeef21aaed73c222719828143c07f1436d6b Mon Sep 17 00:00:00 2001 From: fussykyloren Date: Mon, 11 May 2020 23:11:45 -0500 Subject: [PATCH 3/8] add ruby file --- swap.rb | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 swap.rb diff --git a/swap.rb b/swap.rb new file mode 100644 index 0000000..1dacc40 --- /dev/null +++ b/swap.rb @@ -0,0 +1,5 @@ +def swap!(arr, a, b) + array = arr.dup + array[a], array[b] = array[b], array[a] + array +end \ No newline at end of file From 833bbb204c4b17a69296fbc9a55b76237de853a9 Mon Sep 17 00:00:00 2001 From: fussykyloren Date: Mon, 11 May 2020 23:15:11 -0500 Subject: [PATCH 4/8] add gitignore file --- .gitignore | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c2ac373 --- /dev/null +++ b/.gitignore @@ -0,0 +1,48 @@ +# File created using '.gitignore Generator' for Visual Studio Code: https://bit.ly/vscode-gig + +# Created by https://www.gitignore.io/api/visualstudiocode,macos +# Edit at https://www.gitignore.io/?templates=visualstudiocode,macos + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + +### VisualStudioCode Patch ### +# Ignore all local history of files +.history + +# End of https://www.gitignore.io/api/visualstudiocode,macos + +# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option) + From d219316d7496cc3cc534859ee6cebdc0f5dd270e Mon Sep 17 00:00:00 2001 From: Mitchell Jones <46505941+fussykyloren@users.noreply.github.com> Date: Tue, 12 May 2020 21:13:58 -0500 Subject: [PATCH 5/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b45a139..de57949 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Ruby - Function to Swap Array Elements -## Table of Contents +# Table of Contents - [Information](https://github.com/fussykyloren/ruby-array-swap#information) - [Status](https://github.com/fussykyloren/ruby-array-swap#status) - [Instructions](https://github.com/fussykyloren/ruby-array-swap#instructions) From 1358212aa7140483961f90d2d080b058130a438a Mon Sep 17 00:00:00 2001 From: fussykyloren Date: Thu, 21 May 2020 19:09:02 -0500 Subject: [PATCH 6/8] wrap function in array class --- swap.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/swap.rb b/swap.rb index 1dacc40..72528f1 100644 --- a/swap.rb +++ b/swap.rb @@ -1,5 +1,7 @@ -def swap!(arr, a, b) - array = arr.dup - array[a], array[b] = array[b], array[a] - array +class Array + def swap!(arr, a, b) + array = arr.dup + array[a], array[b] = array[b], array[a] + array + end end \ No newline at end of file From 7e75c5fe08b7082da96cd339ce8098ad60461c15 Mon Sep 17 00:00:00 2001 From: Mitchell Jones <46505941+fussykyloren@users.noreply.github.com> Date: Thu, 21 May 2020 21:29:27 -0500 Subject: [PATCH 7/8] Update README.md --- README.md | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index de57949..6dd95e7 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,17 @@ ruby -v ## Status At this time, the project is __*finished*__. ## Instructions -1. If you do not have ruby installed, follow these [instructions](https://www.ruby-lang.org/en/documentation/installation/). -2. Clone this repository using the following link: https://github.com/fussykyloren/ruby-array-swap.git -3. Use the function as you wish! If you have any suggestions, don't hesitate to raise an issue! +To run these program, Ruby v2.6.3p62 (or a compatible version) will need to be installed. To check the version of ruby you are using, run this command in terminal: +``` +ruby -v +``` +If you do not have ruby installed, follow these [instructions](https://www.ruby-lang.org/en/documentation/installation/). +After ruby is installed, you should clone this repository to a place easily accessible to you using this command in terminal: +``` +git clone https://github.com/fussykyloren/ruby-array-swap.git +``` +Your github username and password should be requested. If not, don't worry about it. +After the repository is cloned, you will need to change the directory to where the game example is saved. To to use the fibonacci programs, run this command next: +``` +cd [LOCATION_OF_CLONED_REPOSITORY] +``` From 6309072d143b15c5e2b83e3557966389019dd684 Mon Sep 17 00:00:00 2001 From: Mitchell Jones <46505941+fussykyloren@users.noreply.github.com> Date: Thu, 21 May 2020 21:32:44 -0500 Subject: [PATCH 8/8] Update README.md --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 6dd95e7..98c929b 100644 --- a/README.md +++ b/README.md @@ -26,3 +26,11 @@ After the repository is cloned, you will need to change the directory to where t ``` cd [LOCATION_OF_CLONED_REPOSITORY] ``` +Now you can move the ruby file to where you will need to use it! This can be done using this command: +``` +mv [LOCATION_OF_CLONED_REPOSITORY]/swap.rb [LOCATION_TO_MOVE_FILE] +``` +Or if you'd prefer, you can copy the file using this command: +``` +cp [LOCATION_OF_CLONED_REPOSITORY]/swap.rb [LOCATION_TO_MOVE_FILE] +```