Class: SiriProxy::Plugin
- Inherits:
-
Cora::Plugin
- Object
- Cora::Plugin
- SiriProxy::Plugin
- Defined in:
- lib/siriproxy/plugin.rb
Instance Attribute Summary collapse
-
#plugin_name ⇒ Object
Returns the value of attribute plugin_name.
Class Method Summary collapse
Instance Method Summary collapse
- #filters ⇒ Object
-
#initialize(config) ⇒ Plugin
constructor
A new instance of Plugin.
- #last_ref_id ⇒ Object
-
#process_filters(object, direction) ⇒ Object
direction should be :from_iphone, or :from_guzzoni.
- #request_completed ⇒ Object
-
#send_object(object, options = {}) ⇒ Object
use send_object(object, target: :guzzoni) to send to guzzoni.
- #to_s ⇒ Object
Constructor Details
#initialize(config) ⇒ Plugin
Returns a new instance of Plugin.
6 7 8 |
# File 'lib/siriproxy/plugin.rb', line 6 def initialize(config) end |
Instance Attribute Details
#plugin_name ⇒ Object
Returns the value of attribute plugin_name.
4 5 6 |
# File 'lib/siriproxy/plugin.rb', line 4 def plugin_name @plugin_name end |
Class Method Details
.filter(class_names, options = {}, &block) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/siriproxy/plugin.rb', line 42 def filter(class_names, ={}, &block) [class_names].flatten.each do |class_name| filters[class_name] = { direction: ([:direction] ||= :both), block: block } end end |
.filters ⇒ Object
51 52 53 |
# File 'lib/siriproxy/plugin.rb', line 51 def filters @filters ||= {} end |
Instance Method Details
#filters ⇒ Object
56 57 58 |
# File 'lib/siriproxy/plugin.rb', line 56 def filters self.class.filters end |
#last_ref_id ⇒ Object
26 27 28 |
# File 'lib/siriproxy/plugin.rb', line 26 def last_ref_id self.manager.iphone_conn.last_ref_id end |
#process_filters(object, direction) ⇒ Object
direction should be :from_iphone, or :from_guzzoni
31 32 33 34 35 36 37 38 39 |
# File 'lib/siriproxy/plugin.rb', line 31 def process_filters(object, direction) return nil if object == nil f = filters[object["class"]] if(f != nil && (f[:direction] == :both || f[:direction] == direction)) object = instance_exec(object, &f[:block]) end object end |
#request_completed ⇒ Object
10 11 12 |
# File 'lib/siriproxy/plugin.rb', line 10 def request_completed self.manager.send_request_complete_to_iphone end |
#send_object(object, options = {}) ⇒ Object
use send_object(object, target: :guzzoni) to send to guzzoni
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/siriproxy/plugin.rb', line 15 def send_object(object, ={}) (object = object.to_hash) rescue nil #convert SiriObjects to a hash [:target] = [:target] ||= :iphone if([:target] == :iphone) self.manager.guzzoni_conn.inject_object_to_output_stream(object) elsif([:target] == :guzzoni) self.manager.iphone_conn.inject_object_to_output_stream(object) end end |
#to_s ⇒ Object
60 61 62 |
# File 'lib/siriproxy/plugin.rb', line 60 def to_s self.plugin_name end |