Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added the "Monkey Patching" facility on DynamicProperties, along wi…
…th tests to ensure it works as advertised. - Added a quick example script.
- Loading branch information
Richard Clayton
committed
Sep 20, 2011
1 parent
983b901
commit 06d28ba
Showing
3 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require_relative 'dynamic_properties' | ||
require "date" | ||
|
||
class WeatherObservation | ||
include Berico::DynamicProperties | ||
|
||
def initialize | ||
@date_time = ::DateTime.now | ||
end | ||
|
||
def to_s | ||
output = "Weather Observation \n" | ||
output << " Time: #{@date_time}\n" | ||
@properties.each do |key, value| | ||
output << " #{key}: #{value}\n" | ||
end | ||
output | ||
end | ||
end | ||
|
||
observation = WeatherObservation.new | ||
|
||
observation.temperature = 75 | ||
observation.dew_point = 25 | ||
observation.wind_speed = 10 | ||
observation.wind_dir = 270 | ||
observation.visibility = 10 | ||
observation.sky_con = :clear | ||
observation.altimeter = 29.92 | ||
|
||
puts observation |
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