This file contains hidden or 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
| # Simple example of basic object oriented concepts and how they work in Ruby | |
| # | |
| # AUTHOR: HAYDEN CHUDY | |
| # First is instance and class variable example | |
| # parent class, keep track of the count of all its children | |
| class Shape | |
| # count class variable. Keeps count of all shapes we have made, in general |
This file contains hidden or 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
| # | |
| # TEXT ANALYZER | |
| # BY: Hayden Chudy | |
| # | |
| # basic setup for text analysis | |
| stopwords = %w{the a by on for of are with just but and to the my I has some in} | |
| lines = File.readlines(ARGV[0]) | |
| line_count = lines.size | |
| text = lines.join |
This file contains hidden or 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
| class Fixnum | |
| def seconds | |
| self | |
| end | |
| def minutes | |
| self * 60 | |
| end | |
| def hours | |
| self * 60 * 60 | |
| end |
This file contains hidden or 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
| /** | |
| * Implements add_to_assoc_numeric | |
| * | |
| * Goal of this function is to allow us to modify an associative, numeric array | |
| * (one that uses string numbers as keys, so there is no 0,1,2,3 ordering, but | |
| * rather the ordering is based on when the keys were inserted [they are treated | |
| * like other string keys]). If we modify this array using array_unshift or | |
| * array_shift, we destory this associative, numeric structure (each key is | |
| * destroyed and the array is simply renumbered, with ints, from 0 to num_elems), | |
| * which we don't want. This function will allow us to insert a new value anywhere |
NewerOlder