Skip to content

Instantly share code, notes, and snippets.

def revolutionize_industry
philosophize(thinker, ideas).each do |idea|
publish(idea)
end
end
def philosophize(thinker, thoughts)
thinker = Philosopher(thinker)
Array(thoughts).map do |thought|
thinker.think(thought)
end
end
def Philosopher(param)
return param if param.kind_of? Philosopher
return Philosopher.find(param) if param.kind_of? Integer
Array(nil) # => []
Array(1) # => [1]
Array([3]) # => [3]
class ArrayLikeThing
def to_a
[1, 2, 3]
end
[11] pry(Kernel):1> ls -m --grep=^[A-Z]
Kernel.methods: Array Complex Float Hash Integer Pathname Rational String
def philosophize(thinker, thoughts)
raise ArgumentError unless thinker.is_a? Philosopher
Array(thoughts).map do |thought|
thinker.think(thought)
end
end
def philosophize(thinker, thoughts)
raise ArgumentError unless thinker.is_a? Philosopher
thoughts = [thoughts] unless thoughts.kind_of? Array
thoughts.map do |thought|
thinker.think(thought)
end
end
def philosophize(thinker, thoughts)
return unless thinker.is_a? Philosopher
thoughts = [thoughts] unless thoughts.kind_of? Array
thoughts.map do |thought|
thinker.think(thought)
end
end
def revolutionize_industry
taken_ideas = philosophize(thinker, ideas)
if !taken_ideas.nil?
taken_ideas.each do |idea|
publish(idea)
end
end
end
def philosophize(thinker, thoughts)
return unless thinker.is_a? Philosopher
if thoughts.kind_of? Array
thoughts.map { |thought| thinker.think(thought) }
else
thinker.think(thought) # => <thought ...>
end
end