Class: UpcomingMoviesInThePark::Park

Inherits:
Object
  • Object
show all
Includes:
Super::GateParkInstanceMethods, Super::InstanceMethods
Defined in:
lib/upcoming_movies_in_the_park/park.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Super::GateParkInstanceMethods

#add_showing, #list_showings

Methods included from Super::InstanceMethods

#save

Constructor Details

#initialize(name) ⇒ Park

Returns a new instance of Park.



13
14
15
16
17
# File 'lib/upcoming_movies_in_the_park/park.rb', line 13

def initialize(name)
  @name = name
  @showings =[]
  self.save
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/upcoming_movies_in_the_park/park.rb', line 2

def name
  @name
end

#showingsObject

Returns the value of attribute showings.



2
3
4
# File 'lib/upcoming_movies_in_the_park/park.rb', line 2

def showings
  @showings
end

Class Method Details

.allObject



9
10
11
# File 'lib/upcoming_movies_in_the_park/park.rb', line 9

def self.all
  @@all
end

.find_or_create_by_name(name) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/upcoming_movies_in_the_park/park.rb', line 19

def self.find_or_create_by_name(name)
  if @@all.any? {|park| park.name == name}
    @@all.find {|park| 
      park.name == name}
  else
    park_1 = self.new(name)
  end
end

.list_by_nameObject



28
29
30
31
# File 'lib/upcoming_movies_in_the_park/park.rb', line 28

def self.list_by_name
  self.all.each_with_index {|park, i|
  puts "#{i +1}. #{park.name}".colorize(:green)}
end