#!/usr/local/bin/ruby class Greeter attr_accessor :name def initialize(name = "world") @name = name end def say_hi if @name.nil? puts "..." elsif @name.respond_to?("each") @name.each do |name| puts "Hi, #{name.capitalize}" end else puts "Hi, #{@name.capitalize}" end end def say_bye puts "Bye, #{@name}" end end if __FILE__ == $0 g1 = Greeter.new "SAM" g1.say_hi g1.say_bye g1.name = [ "paul", "JOHN", "rINGO", "gEoRgE" ] puts "---" g1.say_hi g1.say_bye end