Top Level Namespace
Defined Under Namespace
Modules: JSONRPCOverMQTT
Instance Method Summary collapse
- #hello_world(**kwargs) ⇒ Object
- #logger ⇒ Object
- #ping(**kwargs) ⇒ Object
- #what_time_is_it? ⇒ Boolean
Instance Method Details
#hello_world(**kwargs) ⇒ Object
1 2 3 4 |
# File 'lib/json_rpc_over_mqtt_example/functions/hello_world.rb', line 1 def hello_world(**kwargs) name = kwargs[:name] || "Bob" "Hello World, #{name}!" end |
#logger ⇒ Object
3 4 5 6 7 |
# File 'lib/json_rpc_over_mqtt_example/logger.rb', line 3 def logger @log ||= Logger.new(STDOUT) @log.level = Logger::INFO @log end |
#ping(**kwargs) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/json_rpc_over_mqtt_example/functions/ping.rb', line 3 def ping(**kwargs) url = kwargs[:url] || "google.com" target = Net::Ping::External.new(url) result = target.ping? ? "OK" : "NG" "#{result}: #{url}" end |
#what_time_is_it? ⇒ Boolean
3 4 5 |
# File 'lib/json_rpc_over_mqtt_example/functions/what_time_is_it.rb', line 3 def what_time_is_it? DateTime.now.to_s end |