Skip to content

Instantly share code, notes, and snippets.

@benaskins
Created April 9, 2009 05:33
Show Gist options
  • Save benaskins/92259 to your computer and use it in GitHub Desktop.
Save benaskins/92259 to your computer and use it in GitHub Desktop.
def v1(value)
value || "-"
end
def v2(object, method)
object && value = object.send(method) ? value : "-"
end
.conditions
- if @conditions
%dl
%dt Dew point
%dd= v1 @conditions.dp_c
%dt Relative humidity
%dd= v1 @conditions.rh
%dt feels like
%dd= v1 @conditions.feels_like_c
%dt Wind
%dd= v1 @conditions.wind_dir_and_speed
%dt="Rainfall #{@conditions.rainfall_mm_period}"
%dd= v1 @conditions.rainfall_mm
- else
%dl
%dt Dew point
%dd= v1 nil
%dt Relative humidity
%dd= v1 nil
%dt feels like
%dd= v1 nil
%dt Wind
%dd= v1 nil
%dt="Rainfall #{@conditions.rainfall_mm_period}"
%dd= v1 nil
.conditions
%dl
%dt Dew point
%dd= v2 @conditions, :dp_c
%dt Relative humidity
%dd= v2 @conditions, :rh
%dt feels like
%dd= v2 @conditions, :feels_like_c
%dt Wind
%dd= v2 @conditions, :wind_dir_and_speed
%dt="Rainfall #{@conditions.rainfall_mm_period if @conditions}"
%dd= v2 @conditions, :rainfall_mm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment