Skip to content
Browse files

opacity

  • Loading branch information...
1 parent 859d773 commit 1d855016ecb211bf69e62a38678f431b2a07a03f @hc5duke committed
Showing with 33 additions and 14 deletions.
  1. +8 −8 app/controllers/index_controller.rb
  2. +11 −0 app/helpers/index_helper.rb
  3. +14 −6 app/views/index/index.html.haml
View
16 app/controllers/index_controller.rb
@@ -12,24 +12,24 @@ def index
private
+ HOME_STATIONS = %w(dubl)
+ DOWNTOWN_STATIONS = %w(16th civc powl mont embr woak)
+ EASTBOUND_DESTINATIONS = %w(PITT FRMT RICH SHAY DUBL CONC NCON MONT)
+
def morning
- @stations = %w(dubl).map do |abbreviation|
+ @stations = HOME_STATIONS.map do |abbreviation|
Bort::Realtime::Estimates.new(abbreviation)
end
- @destinations = @stations.map do |station|
- station.destinations
- end.flatten.uniq
+ @destinations = @stations.map(&:destinations).flatten.uniq
end
def evening
@is_evening = true
- @stations = %w(16th civc powl mont embr woak).map do |abbreviation|
+ @stations = DOWNTOWN_STATIONS.map do |abbreviation|
Bort::Realtime::Estimates.new(abbreviation)
end
- @destinations = @stations.map do |station|
- station.destinations
- end.flatten.uniq - %w(PITT FRMT RICH SHAY DUBL CONC NCON MONT)
+ @destinations = @stations.map(&:destinations).flatten.uniq - EASTBOUND_DESTINATIONS
end
end
View
11 app/helpers/index_helper.rb
@@ -0,0 +1,11 @@
+module IndexHelper
+ def opacity_class(train)
+ if train.minutes >= 50
+ 'future'
+ end
+ end
+
+ def train_length(train)
+ train.length % 10
+ end
+end
View
20 app/views/index/index.html.haml
@@ -5,13 +5,15 @@
- trains = station.trains.select{|train|@destinations.include?(train.destination)}
%tr
%th= station.origin
- - trains.sort_by(&:minutes).each do |train|
- %td{:class => "dest_#{train.destination.downcase}"}
+ - trains.sort_by(&:minutes).first(6).each do |train|
+ %td{:class => "dest_#{train.destination.downcase} #{opacity_class(train)}"}
%span.minute= train.minutes
%br
- %span.destination= train.destination
+ %span.destination
+ = train.destination[0,2]
+ = train_length(train)
- (6 - trains.length).times do
- %td .
+ %td.future .
- if @is_evening
%h3 »Dublin
@@ -22,10 +24,13 @@
%tr
%th= station.origin
- trains.sort_by(&:minutes).each do |train|
- %td
+ %td{:class => opacity_class(train)}
%span.minute= train.minutes
+ %br
+ %span.destination
+ = train_length(train)
- (6 - trains.length).times do
- %td .
+ %td.future .
- content_for :page_styles do
:plain
@@ -51,3 +56,6 @@
td.dest_24th {
background-color: #eeaaee;
}
+ td.future {
+ opacity: 0.2;
+ }

0 comments on commit 1d85501

Please sign in to comment.
Something went wrong with that request. Please try again.