class Wetter
#¶ ↑
require 'wetter/constants.rb'
#¶ ↑
#¶ ↑
require 'wetter/menu.rb'
#¶ ↑
#¶ ↑
require 'wetter/toplevel_methods/is_on_roebe.rb'
#¶ ↑
Constants
- N
#¶ ↑
N
¶ ↑#¶ ↑
- TRY_TO_MAKE_USE_OF_THE_UNICODE_WEATHER_SYMBOL
#¶ ↑
TRY_TO_MAKE_USE_OF_THE_UNICODE_WEATHER_SYMBOL
¶ ↑If the next constant is set to true then class
Wetter
will try to make use of the unicode symbol for “cloudy weather”.#¶ ↑
- URL
#¶ ↑
URL
¶ ↑Point to the remote website that holds the information for the local temperature in the city of Vienna.
#¶ ↑
- USE_DEGREE_REGEX
#¶ ↑
USE_DEGREE_REGEX
¶ ↑This second regex can be used when we wish to match against ° values.
#¶ ↑
- USE_THIS_REGEX
#¶ ↑
USE_THIS_REGEX
¶ ↑#¶ ↑
Public Class Methods
current_degrees()
click to toggle source
is_on_roebe?()
click to toggle source
new( optional_commandline_arguments = ARGV, run_already = true ) { || ... }
click to toggle source
#¶ ↑
initialize¶ ↑
#¶ ↑
# File lib/wetter/wetter.rb, line 33 def initialize( optional_commandline_arguments = ARGV, run_already = true ) reset if block_given? yielded = yield case yielded when :be_silent @be_verbose = false end end if optional_commandline_arguments menu(optional_commandline_arguments) end run if run_already end
run( i = ARGV )
click to toggle source
start_sinatra_interface()
click to toggle source
Public Instance Methods
cliner()
click to toggle source
debug?()
click to toggle source
enable_debug_mode()
click to toggle source
find_match()
click to toggle source
match?()
click to toggle source
read_in_dataset_from_remote_webpage()
click to toggle source
report_result()
click to toggle source
#¶ ↑
report_result
¶ ↑
#¶ ↑
# File lib/wetter/wetter.rb, line 150 def report_result if @be_verbose n_degrees_celsius = match?.to_f result = "The current temperature in Vienna is: "\ "#{sfancy(n_degrees_celsius)} °C".dup if try_to_make_use_of_the_unicode_weather_symbol? begin require 'roebe/toplevel_methods/unicode/popular_unicode_symbols.rb' case n_degrees_celsius when 16..50 # Should be clear weather most of the time. result << " #{tomato(Roebe.clear_weather)}" when 5..15 # Medium-temperature; usually cloudy. result << " #{royalblue(Roebe.cloudy_weather_symbol)}" when -30..4 # It's really quite cold. result << " #{royalblue(Roebe.snowman)}" end rescue LoadError end end opn; e result end end
reset()
click to toggle source
royalblue(i = '')
click to toggle source
run()
click to toggle source
sanitize_dataset()
click to toggle source
#¶ ↑
sanitize_dataset
¶ ↑
#¶ ↑
# File lib/wetter/wetter.rb, line 83 def sanitize_dataset splitted = @data.split(N) splitted.reject! {|line| ! (line.include?('title="Wien Innere Stadt') and line.include?('Temp: ')) } splitted = splitted.first if splitted.is_a? Array if debug? opn; e 'Now showing the sanitized dataset, as we run in @debug mode.' pp splitted end @data = splitted if @data.nil? @data =~ USE_DEGREE_REGEX unless $1.to_s.dup.empty? @data = $1.to_s.dup end end end
show_help()
click to toggle source
show_the_remote_url()
click to toggle source
tomato(i = '')
click to toggle source