Class: Guh::Base
- Inherits:
-
Object
- Object
- Guh::Base
- Defined in:
- lib/guh/base.rb
Overview
The base class which all the specific wrapper classes inherit from. It provides some shared code to make development easier.
Direct Known Subclasses
Action, Device, DeviceClass, Event, EventType, Plugin, Rule, State, StateType, Vendor
Constant Summary collapse
- @@guh_ip_address =
"127.0.0.1"
- @@guh_port =
1234
Class Method Summary collapse
-
.configure {|_self| ... } ⇒ Object
Configuration DSL helper method.
-
.get(request_hash) ⇒ Object
Don’t use this unless you know what you are doing!.
-
.guh_ip_address ⇒ Object
Getter/Setter for the guh_ip_address attribute.
-
.guh_ip_address=(hia) ⇒ Object
:nodoc:.
-
.guh_port ⇒ Object
Getter/Setter for the guh_port attribute.
-
.guh_port=(hia) ⇒ Object
:nodoc:.
-
.introspect ⇒ Object
Returns everything that is going on inside guh Core.
- .version ⇒ Object
Class Method Details
.configure {|_self| ... } ⇒ Object
Configuration DSL helper method.
The default values are:
-
guh_ip_address
: 127.0.0.1 -
guh_port
: 1234
Example:
Guh::Base.configure do |config|
config.guh_ip_address = 10.0.0.1
config.guh_port = 6789
end
85 86 87 |
# File 'lib/guh/base.rb', line 85 def self.configure(&block) yield self end |
.get(request_hash) ⇒ Object
Don’t use this unless you know what you are doing!
Send a request to guh Core and fetch the Response. This is a utility method used by the subclasses.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/guh/base.rb', line 53 def self.get(request_hash) request_string = hash_to_json(request_hash) response = nil client do |c| c.puts(request_string) response = (c) end if response['status'] == 'success' return response['params'] else raise Guh::ResponseError, "The Request was not successful: #{response['error']}" end end |
.guh_ip_address ⇒ Object
Getter/Setter for the guh_ip_address attribute
8 9 10 |
# File 'lib/guh/base.rb', line 8 def self.guh_ip_address #:nodoc: @@guh_ip_address end |
.guh_ip_address=(hia) ⇒ Object
:nodoc:
11 12 13 |
# File 'lib/guh/base.rb', line 11 def self.guh_ip_address=(hia) #:nodoc: @@guh_ip_address=hia end |
.guh_port ⇒ Object
Getter/Setter for the guh_port attribute
17 18 19 |
# File 'lib/guh/base.rb', line 17 def self.guh_port #:nodoc: @@guh_port end |
.guh_port=(hia) ⇒ Object
:nodoc:
20 21 22 |
# File 'lib/guh/base.rb', line 20 def self.guh_port=(hia) #:nodoc: @@guh_port=hia end |
.introspect ⇒ Object
33 34 35 36 37 38 |
# File 'lib/guh/base.rb', line 33 def self.introspect get({ id: generate_request_id, method: "JSONRPC.Introspect", }) end |
.version ⇒ Object
40 41 42 43 44 45 |
# File 'lib/guh/base.rb', line 40 def self.version get({ id: generate_request_id, method: "JSONRPC.Version", }) end |