Skip to content

Commit

Permalink
minor method refactorings.
Browse files Browse the repository at this point in the history
  • Loading branch information
botandrose-machine committed Sep 19, 2015
1 parent f4086be commit 9f29cbe
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions app/models/calagator/event.rb
Expand Up @@ -102,12 +102,12 @@ class Event < ActiveRecord::Base

# Return the title but strip out any whitespace.
def title
read_attribute(:title).to_s.strip
super.strip if super

This comment has been minimized.

Copy link
@reidab

reidab Sep 24, 2015

Member

At some point, I'd be in favor of sanitizing these on save instead of on display.

This comment has been minimized.

Copy link
@botandrose

botandrose Sep 24, 2015

Contributor

I'd actually like to do some git spelunking to figure out what component actually cares about these whitespace mungings, and move them there. Cuz html don't care. Maybe iCal cares?

end

# Return description without those pesky carriage-returns.
def description
read_attribute(:description).to_s.gsub("\r\n", "\n").gsub("\r", "\n")
super.gsub(/\r\n?/, "\n") if super
end

def url=(value)
Expand Down Expand Up @@ -178,15 +178,13 @@ def old?
end

def ongoing?
start_time < Date.today.to_time && end_time && end_time >= Date.today.to_time
return unless end_time && start_time
(start_time..end_time).cover?(Date.today.to_time)
end

def duration
if end_time && start_time
(end_time - start_time)
else
0
end
return 0 unless end_time && start_time
(end_time - start_time)
end
end

Expand Down

0 comments on commit 9f29cbe

Please sign in to comment.