Class: UpcomingMoviesInThePark::Gate
- Inherits:
-
Object
- Object
- UpcomingMoviesInThePark::Gate
- Defined in:
- lib/upcoming_movies_in_the_park/gate.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#day ⇒ Object
Returns the value of attribute day.
-
#month ⇒ Object
Returns the value of attribute month.
-
#name ⇒ Object
Returns the value of attribute name.
-
#showings ⇒ Object
Returns the value of attribute showings.
-
#year ⇒ Object
Returns the value of attribute year.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name) ⇒ Gate
constructor
A new instance of Gate.
Methods included from Super::GateParkInstanceMethods
Methods included from Super::InstanceMethods
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
#day ⇒ Object
Returns the value of attribute day.
2 3 4 |
# File 'lib/upcoming_movies_in_the_park/gate.rb', line 2 def day @day end |
#month ⇒ Object
Returns the value of attribute month.
2 3 4 |
# File 'lib/upcoming_movies_in_the_park/gate.rb', line 2 def month @month end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/upcoming_movies_in_the_park/gate.rb', line 2 def name @name end |
#showings ⇒ Object
Returns the value of attribute showings.
2 3 4 |
# File 'lib/upcoming_movies_in_the_park/gate.rb', line 2 def showings @showings end |
#year ⇒ Object
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
.all ⇒ Object
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_date ⇒ Object
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 |