Class: NycToday::Event
- Inherits:
-
Object
- Object
- NycToday::Event
- Defined in:
- lib/nyc_today/event.rb
Constant Summary collapse
- @@all =
[]
- @@sets =
[]
Instance Attribute Summary collapse
-
#event_info ⇒ Object
Returns the value of attribute event_info.
-
#event_link ⇒ Object
Returns the value of attribute event_link.
-
#event_type ⇒ Object
Returns the value of attribute event_type.
-
#name ⇒ Object
Returns the value of attribute name.
-
#price ⇒ Object
Returns the value of attribute price.
-
#time ⇒ Object
Returns the value of attribute time.
-
#time_stamp ⇒ Object
Returns the value of attribute time_stamp.
-
#venue ⇒ Object
Returns the value of attribute venue.
Class Method Summary collapse
- .all ⇒ Object
- .event_sets(input) ⇒ Object
- .event_types ⇒ Object
- .midnight_fix ⇒ Object
- .reformat_types ⇒ Object
- .reset_sets ⇒ Object
- .sets ⇒ Object
- .sort_events ⇒ Object
Instance Method Summary collapse
-
#initialize(hash) ⇒ Event
constructor
A new instance of Event.
Constructor Details
#initialize(hash) ⇒ Event
Returns a new instance of Event.
7 8 9 10 11 12 |
# File 'lib/nyc_today/event.rb', line 7 def initialize(hash) hash.each do |key, value| self.send("#{key}=", value) end @@all << self end |
Instance Attribute Details
#event_info ⇒ Object
Returns the value of attribute event_info.
2 3 4 |
# File 'lib/nyc_today/event.rb', line 2 def event_info @event_info end |
#event_link ⇒ Object
Returns the value of attribute event_link.
2 3 4 |
# File 'lib/nyc_today/event.rb', line 2 def event_link @event_link end |
#event_type ⇒ Object
Returns the value of attribute event_type.
2 3 4 |
# File 'lib/nyc_today/event.rb', line 2 def event_type @event_type end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/nyc_today/event.rb', line 2 def name @name end |
#price ⇒ Object
Returns the value of attribute price.
2 3 4 |
# File 'lib/nyc_today/event.rb', line 2 def price @price end |
#time ⇒ Object
Returns the value of attribute time.
2 3 4 |
# File 'lib/nyc_today/event.rb', line 2 def time @time end |
#time_stamp ⇒ Object
Returns the value of attribute time_stamp.
2 3 4 |
# File 'lib/nyc_today/event.rb', line 2 def time_stamp @time_stamp end |
#venue ⇒ Object
Returns the value of attribute venue.
2 3 4 |
# File 'lib/nyc_today/event.rb', line 2 def venue @venue end |
Class Method Details
.all ⇒ Object
14 15 16 |
# File 'lib/nyc_today/event.rb', line 14 def self.all @@all end |
.event_sets(input) ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/nyc_today/event.rb', line 46 def self.event_sets(input) choice = event_types[input] event_group = [] all.each do |event| event.event_type.downcase == choice.downcase ? event_group << event : nil end @@sets = event_group.sort_by!{|e|e.time_stamp} sort_events end |
.event_types ⇒ Object
26 27 28 |
# File 'lib/nyc_today/event.rb', line 26 def self.event_types all.sort_by!{|e|e.event_type.length}.collect{|event|event.event_type}.uniq! end |
.midnight_fix ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/nyc_today/event.rb', line 56 def self.midnight_fix midnight = [] @@sets.reject! do |e| e.time_stamp.to_s[11].to_i == 0 && e.time_stamp.to_s[12].to_i < 7 ? midnight << e : nil end midnight end |
.reformat_types ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/nyc_today/event.rb', line 30 def self.reformat_types all.each do |event| if event.event_type.include?("Dj") event.event_type.sub!("j", "J") elsif event.event_type.include?("Food") event.event_type.insert(4, ",").insert(10, " &") elsif event.event_type.include?("Talks") event.event_type = event.event_type.insert(8, " &") elsif event.event_type.include?("Theatre") event.event_type.insert(7, " &") else event.event_type end end end |
.reset_sets ⇒ Object
22 23 24 |
# File 'lib/nyc_today/event.rb', line 22 def self.reset_sets sets.clear end |
.sets ⇒ Object
18 19 20 |
# File 'lib/nyc_today/event.rb', line 18 def self.sets @@sets end |
.sort_events ⇒ Object
64 65 66 67 |
# File 'lib/nyc_today/event.rb', line 64 def self.sort_events midnight_fix.sort_by!{|e|e.time_stamp} @@sets = @@sets.push(*midnight_fix).each_slice(5).to_a end |