Class: UpcomingMoviesInThePark::Showing

Inherits:
Object
  • Object
show all
Includes:
UpcomingMoviesInThePark::Super::InstanceMethods
Defined in:
lib/upcoming_movies_in_the_park/showing.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from UpcomingMoviesInThePark::Super::InstanceMethods

#save

Instance Attribute Details

#dateObject

Returns the value of attribute date.



5
6
7
# File 'lib/upcoming_movies_in_the_park/showing.rb', line 5

def date
  @date
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/upcoming_movies_in_the_park/showing.rb', line 4

def name
  @name
end

#parkObject

Returns the value of attribute park.



5
6
7
# File 'lib/upcoming_movies_in_the_park/showing.rb', line 5

def park
  @park
end

#urlObject

Returns the value of attribute url.



4
5
6
# File 'lib/upcoming_movies_in_the_park/showing.rb', line 4

def url
  @url
end

Class Method Details

.allObject



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

def self.all
  @@all
end

.create_from_hash(hash) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/upcoming_movies_in_the_park/showing.rb', line 38

def self.create_from_hash(hash)
  thing = UpcomingMoviesInThePark::Showing.new
  hash.each do |k,v|
    thing.send("#{k}=", v)
  end
  @@all<<thing
end

.list_by_nameObject



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

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

Instance Method Details

#display_detailsObject



18
19
20
21
# File 'lib/upcoming_movies_in_the_park/showing.rb', line 18

def display_details
  puts "#{@name} is playing from #{self.time}".colorize(:red)
  puts "on #{@date.month} #{@date.day}, #{@date.year} in #{@park.name}.".colorize(:red)
end

#timeObject



23
24
25
26
# File 'lib/upcoming_movies_in_the_park/showing.rb', line 23

def time
  data = self.date.name.split(/, | |\n/)
  time = "#{data[37]} #{data[38]} to #{data[40]} #{data[41]}"
end