Languages
6,428 gist results
6,428 gist results
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 Cat | |
| attr_reader :color, :breed | |
| attr_accessor :name | |
| def initialize(color, breed) | |
| @color = color # instance variable | |
| @breed = breed # instance variable | |
| @hungry = true | |
| 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
| output = '' | |
| animals = ['cat', 'dog', 'bird'] | |
| animals.each do |animal| | |
| output += output + animal + ' ' | |
| end | |
| puts output # cat cat dog cat cat dog bird |
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 Cat | |
| attr_reader :color, :breed | |
| attr_accessor :name | |
| def initialize(color, breed) | |
| @color = color | |
| @breed = breed | |
| @hungry = true | |
| end | |
| def feed(food) | |
| puts "Mmmm, " + food + "!" |
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 Pet | |
| attr_reader :color, :breed | |
| attr_accessor :name | |
| def initialize(color, breed) | |
| @color = color | |
| @breed = breed | |
| @hungry = true | |
| 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
| class Cat | |
| attr_reader :color, :breed | |
| attr_accessor :name | |
| def initialize(color,breed) | |
| @color = color | |
| @breed = breed | |
| @hungry = true | |
| 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
| # Stats about a single log | |
| class Log | |
| # Load a file and parse every line as a print. | |
| def self.parse(file_path) | |
| Log.new(file_path, File.readlines(file_path)) | |
| end | |
| # Number of lines in the file and number of lines that are valid CATS prints | |
| attr_reader :linecount, :cats_linecount, | |
| # Number of characters that are in the file, part of CATS prints and part of CATS header overhead, respectively |
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 Cat | |
| attr_reader:color, :breed | |
| attr_accessor:name | |
| def initialize(color, breed) | |
| @color = color | |
| @breed = breed | |
| @hungry = true | |
| end | |
| def feed(food) | |
| puts "Mmmm, " + food + "!" |
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 Pet | |
| attr_reader :color, :breed | |
| attr_accessor :name | |
| def initialize(color, breed) | |
| @color = color | |
| @breed = breed | |
| @hungry = true | |
| 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
| class Pet | |
| attr_reader :color, :breed | |
| attr_accessor :name | |
| def initialize(color, breed) | |
| @color = color | |
| @breed = breed | |
| @hungry = true | |
| 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
| class Pet | |
| attr_reader :color, :breed | |
| attr_accessor :name | |
| def initialize(color, breed) | |
| @color = color | |
| @breed = breed | |
| @hungry = true | |
| end |