Created
April 9, 2009 05:33
-
-
Save benaskins/92259 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def v1(value) | |
value || "-" | |
end | |
def v2(object, method) | |
object && value = object.send(method) ? value : "-" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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