Class: RubyQuiz2::PeopleList

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/ruby_quiz_2/people_list.rb

Instance Method Summary collapse

Constructor Details

#initialize(list = nil) ⇒ PeopleList

Returns a new instance of PeopleList.



5
6
7
# File 'lib/ruby_quiz_2/people_list.rb', line 5

def initialize(list=nil)
  import list if list
end

Instance Method Details

#eachObject



17
18
19
# File 'lib/ruby_quiz_2/people_list.rb', line 17

def each
  people.each { |person| yield person }
end

#lengthObject



13
14
15
# File 'lib/ruby_quiz_2/people_list.rb', line 13

def length
  people.length
end

#peopleObject



9
10
11
# File 'lib/ruby_quiz_2/people_list.rb', line 9

def people
  @people ||= []
end