Skip to content

class Cat
attr_reader :color, :breed
attr_accessor :name
def initialize(color, breed)
@color = color # instance variable
@breed = breed # instance variable
@hungry = true
end
output = ''
animals = ['cat', 'dog', 'bird']
animals.each do |animal|
output += output + animal + ' '
end
puts output # cat cat dog cat cat dog bird
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 + "!"
@LucieKla
LucieKla / cat.rb
Last active May 7, 2017 13:20
Cat
class Pet
attr_reader :color, :breed
attr_accessor :name
def initialize(color, breed)
@color = color
@breed = breed
@hungry = true
end
class Cat
attr_reader :color, :breed
attr_accessor :name
def initialize(color,breed)
@color = color
@breed = breed
@hungry = true
end
@wvdschel
wvdschel / gist:2627572
Created May 7, 2012 12:47
Cats parser
# 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
@dapolls
dapolls / cats.rb
Created January 26, 2016 14:39
RUBY cat
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 + "!"
@coreynicho11
coreynicho11 / cat.rb
Last active February 9, 2017 17:57
cat.rb
class Pet
attr_reader :color, :breed
attr_accessor :name
def initialize(color, breed)
@color = color
@breed = breed
@hungry = true
end
@ruthjohnstonmusic
ruthjohnstonmusic / cat.rb
Last active February 26, 2018 17:08
Cat ruby
class Pet
attr_reader :color, :breed
attr_accessor :name
def initialize(color, breed)
@color = color
@breed = breed
@hungry = true
end
@clemoon
clemoon / cat.rb
Last active May 15, 2017 09:40
cat.rb
class Pet
attr_reader :color, :breed
attr_accessor :name
def initialize(color, breed)
@color = color
@breed = breed
@hungry = true
end