Class: UpcomingMoviesInThePark::Gate

Inherits:
Object
  • Object
show all
Includes:
Super::GateParkInstanceMethods, Super::InstanceMethods
Defined in:
lib/upcoming_movies_in_the_park/gate.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) ⇒ Gate

Returns a new instance of Gate.



13
14
15
16
17
18
19
20
21
# File 'lib/upcoming_movies_in_the_park/gate.rb', line 13

def initialize(name)
  @showings =[]
  @name = name
  self.save
  data = name.split(/, | /)
  @month = data[31]
  @day = data[32]
  @year = data[33]
end

Instance Attribute Details

#dayObject

Returns the value of attribute day.



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

def day
  @day
end

#monthObject

Returns the value of attribute month.



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

def month
  @month
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#showingsObject

Returns the value of attribute showings.



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

def showings
  @showings
end

#yearObject

Returns the value of attribute year.



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

def year
  @year
end

Class Method Details

.allObject



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

def self.all
  @@all
end

.find_or_create_by_name(name) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/upcoming_movies_in_the_park/gate.rb', line 23

def self.find_or_create_by_name(name)
  data = name.split(/, | /)
  if @@all.any? {|gate| data[31] == gate.month && data[32] == gate.day && data[33] = gate.year}
    @@all.find {|gate| data[31] == gate.month && data[32] == gate.day && data[33] = gate.year}
  else
    gate_1 = self.new(name)
  end
end

.list_by_dateObject



32
33
34
35
# File 'lib/upcoming_movies_in_the_park/gate.rb', line 32

def self.list_by_date
  self.all.each_with_index {|gate, i|
    puts "#{i +1}. #{gate.month} #{gate.day}, #{gate.year}".colorize(:green)}
end