Skip to content

Instantly share code, notes, and snippets.

@mrsweaters
Last active August 29, 2015 14:03
Show Gist options
  • Select an option

  • Save mrsweaters/3e6ff7f9d136144d0745 to your computer and use it in GitHub Desktop.

Select an option

Save mrsweaters/3e6ff7f9d136144d0745 to your computer and use it in GitHub Desktop.
Ruby Classe Stuff
names = []
@topics.each do |topic|
names << topic.name
end
names
names = @topics.map do |topic|
topic.name
end
@topics.map(&:name)
class Topic
def initialize(opts)
@name = opts[:name]
appendage = opts[:appendage]
end
def self.wow
'not wow'
end
def self.recent_topics
where('created_at > ?', 1.day.ago)
end
def name
@name
end
end
t = Topic.recent_topics.first
t.name
topic = Topic.new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment