Class: Andromeda::Impl::ProtoPlan
- Inherits:
-
ConnectorBase
- Object
- ConnectorBase
- Andromeda::Impl::ProtoPlan
- Extended by:
- ClassAttr
- Includes:
- To_S
- Defined in:
- lib/andromeda/impl/proto_plan.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#guide ⇒ Object
Returns the value of attribute guide.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Class Method Summary collapse
- .name_spot(*names) ⇒ Object
- .signal_names(inherit = true) ⇒ Object
- .signal_spot(*names) ⇒ Object
- .spot_attr(*names) ⇒ Object
- .spot_attr_names(inherit = true) ⇒ Object
- .spot_meth(name, opts = {}) ⇒ Object
- .spot_meth_names(inherit = true) ⇒ Object
- .spot_names(inherit = true) ⇒ Object
Instance Method Summary collapse
- #>>(spot) ⇒ Object
- #current_name ⇒ Object
- #current_scope ⇒ Object
-
#data_key(name, data) ⇒ Object
Override to extract the data key from mapped, incoming data, defaults to name.
-
#data_tag(name, key, val, tags_in) ⇒ Object
Override to compute additional tags.
-
#data_val(name, data) ⇒ Object
Override to extract the data value from mapped, incoming data, defaults to data.
- #dest ⇒ Object
- #entry ⇒ Object
- #init_guide ⇒ Object
-
#initialize(config = {}) ⇒ ProtoPlan
constructor
A new instance of ProtoPlan.
- #initialize_copy(other) ⇒ Object
-
#key_label(name, key) ⇒ Object
Override to determine the target track label from the key, defaults to key.
-
#key_spot(name, key) ⇒ Object
Override to determine the target spot name from the key, defaults to name.
-
#map_data(name, data) ⇒ Object
Override to map all incoming data, default to data.
- #mute ⇒ Object
- #post_data(spot_, track_in, data, tags_in = {}) ⇒ Object
- #post_to(track, data, tags_in = {}) ⇒ Object
-
#public_spot(name) ⇒ Spot?
public spot with name name if any, nil otherwise.
-
#selects?(name, key, val, tags_in) ⇒ Boolean
Override to filter the data events that should be processed, defaults to true.
- #signal_name?(name) ⇒ Boolean
- #signal_names ⇒ Object
- #spot_attr_name?(name) ⇒ Boolean
- #spot_attr_names ⇒ Object
- #spot_meth_name?(name) ⇒ Boolean
- #spot_meth_names ⇒ Object
- #spot_name?(name) ⇒ Boolean
- #spot_names ⇒ Object
- #tags ⇒ Object
- #to_short_s ⇒ Object
- #via(spot_name) ⇒ Object
Methods included from To_S
Methods inherited from ConnectorBase
Constructor Details
Instance Attribute Details
#guide ⇒ Object
Returns the value of attribute guide.
43 44 45 |
# File 'lib/andromeda/impl/proto_plan.rb', line 43 def guide @guide end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
42 43 44 |
# File 'lib/andromeda/impl/proto_plan.rb', line 42 def id @id end |
Class Method Details
.name_spot(*names) ⇒ Object
13 |
# File 'lib/andromeda/impl/proto_plan.rb', line 13 def self.name_spot(*names) ; name_attr_set '@spot_names', *names end |
.signal_names(inherit = true) ⇒ Object
39 |
# File 'lib/andromeda/impl/proto_plan.rb', line 39 def self.signal_names(inherit = true) ; get_attr_set '@signal_names', inherit end |
.signal_spot(*names) ⇒ Object
40 |
# File 'lib/andromeda/impl/proto_plan.rb', line 40 def self.signal_spot(*names) ; name_attr_set '@signal_names', *names end |
.spot_attr(*names) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/andromeda/impl/proto_plan.rb', line 23 def self.spot_attr(*names) name_spot *names name_attr_set '@spot_attr_names', *names attr_writer *names names.each do |name| define_method :"#{name}" do || intern (instance_variable_get("@#{name}")) end define_method :"#{name}=" do |val| if val then instance_variable_set "@#{name}", intern(val.entry) else instance_variable_set "@#{name}", nil end end end end |
.spot_attr_names(inherit = true) ⇒ Object
11 |
# File 'lib/andromeda/impl/proto_plan.rb', line 11 def self.spot_attr_names(inherit = true) ; get_attr_set '@spot_attr_names', inherit end |
.spot_meth(name, opts = {}) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/andromeda/impl/proto_plan.rb', line 15 def self.spot_meth(name, opts = {}) name_spot name name_attr_set '@spot_meth_names', name define_method :"#{name}" do || mk_spot name, opts = {} end end |
.spot_meth_names(inherit = true) ⇒ Object
12 |
# File 'lib/andromeda/impl/proto_plan.rb', line 12 def self.spot_meth_names(inherit = true) ; get_attr_set '@spot_meth_names', inherit end |
.spot_names(inherit = true) ⇒ Object
10 |
# File 'lib/andromeda/impl/proto_plan.rb', line 10 def self.spot_names(inherit = true) ; get_attr_set '@spot_names', inherit end |
Instance Method Details
#>>(spot) ⇒ Object
153 154 155 156 157 |
# File 'lib/andromeda/impl/proto_plan.rb', line 153 def >>(spot) @emit = spot.entry d = spot.dest if d then d else spot end end |
#current_name ⇒ Object
151 |
# File 'lib/andromeda/impl/proto_plan.rb', line 151 def current_name ; [:name] end |
#current_scope ⇒ Object
150 |
# File 'lib/andromeda/impl/proto_plan.rb', line 150 def current_scope ; [:scope] end |
#data_key(name, data) ⇒ Object
Override to extract the data key from mapped, incoming data, defaults to name
77 |
# File 'lib/andromeda/impl/proto_plan.rb', line 77 def data_key(name, data) ; name end |
#data_tag(name, key, val, tags_in) ⇒ Object
Override to compute additional tags
89 |
# File 'lib/andromeda/impl/proto_plan.rb', line 89 def data_tag(name, key, val, ) ; { name: name } end |
#data_val(name, data) ⇒ Object
Override to extract the data value from mapped, incoming data, defaults to data
86 |
# File 'lib/andromeda/impl/proto_plan.rb', line 86 def data_val(name, data) ; data end |
#dest ⇒ Object
160 |
# File 'lib/andromeda/impl/proto_plan.rb', line 160 def dest ; emit end |
#entry ⇒ Object
159 |
# File 'lib/andromeda/impl/proto_plan.rb', line 159 def entry ; enter end |
#init_guide ⇒ Object
57 |
# File 'lib/andromeda/impl/proto_plan.rb', line 57 def init_guide ; Guides.default end |
#initialize_copy(other) ⇒ Object
52 53 54 55 |
# File 'lib/andromeda/impl/proto_plan.rb', line 52 def initialize_copy(other) @tags = @tags.identical_copy @tags ||= {} end |
#key_label(name, key) ⇒ Object
Override to determine the target track label from the key, defaults to key
83 |
# File 'lib/andromeda/impl/proto_plan.rb', line 83 def key_label(name, key) ; key end |
#key_spot(name, key) ⇒ Object
Override to determine the target spot name from the key, defaults to name
80 |
# File 'lib/andromeda/impl/proto_plan.rb', line 80 def key_spot(name, key) ; name end |
#map_data(name, data) ⇒ Object
Override to map all incoming data, default to data
74 |
# File 'lib/andromeda/impl/proto_plan.rb', line 74 def map_data(name, data) ; data end |
#mute ⇒ Object
161 |
# File 'lib/andromeda/impl/proto_plan.rb', line 161 def mute ; @emit = nil end |
#post_data(spot_, track_in, data, tags_in = {}) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/andromeda/impl/proto_plan.rb', line 94 def post_data(spot_, track_in, data, = {}) raise ArgumentError, "#{spot_} is not a Spot" unless spot_.is_a?(Spot) raise ArgumentError, "#{spot_} is not a Spot of this Plan" unless spot_.plan == self name = spot_.name details = { name: name, data: data, tags_in: , spot: spot_ } begin data = map_data name, data key = data_key name, data name = key_spot name, key guide_ = guide label = key_label name, key details[:label] = label track_ = guide_.track spot_, label, track_in details[:track] = track_ value = data_val name, data details[:val] = value .update data_tag name, key, value, .update guide_.provision track_, label, pack_ = guide_.pack self, track_, track_.equal?(track_in) details[:pack] = pack_ meth = pack_.method :"on_#{name}" if selects? name, key, value, pack_.transport_data name, track_, meth, key, value, end rescue Exception => e raise SendError, InfoMsg.str('send_data failed', details, e), e.backtrace end end |
#post_to(track, data, tags_in = {}) ⇒ Object
164 |
# File 'lib/andromeda/impl/proto_plan.rb', line 164 def post_to(track, data, = {}) ; start.post_to track, data, end |
#public_spot(name) ⇒ Spot?
Returns public spot with name name if any, nil otherwise.
130 131 132 133 134 135 136 137 138 |
# File 'lib/andromeda/impl/proto_plan.rb', line 130 def public_spot(name) raise ArgumentError, "#{name} is not a Symbol" unless name.is_a? Symbol raise ArgumentError, "#{name} is not a known spot name" unless spot_name? name if respond_to?(name) then intern public_send(name) else nil end end |
#selects?(name, key, val, tags_in) ⇒ Boolean
Override to filter the data events that should be processed, defaults to true
92 |
# File 'lib/andromeda/impl/proto_plan.rb', line 92 def selects?(name, key, val, ) ; true end |
#signal_name?(name) ⇒ Boolean
143 |
# File 'lib/andromeda/impl/proto_plan.rb', line 143 def signal_name?(name) ; signal_names.include? name end |
#signal_names ⇒ Object
148 |
# File 'lib/andromeda/impl/proto_plan.rb', line 148 def signal_names ; self.class.signal_names end |
#spot_attr_name?(name) ⇒ Boolean
141 |
# File 'lib/andromeda/impl/proto_plan.rb', line 141 def spot_attr_name?(name) ; spot_attr_names.include? name end |
#spot_attr_names ⇒ Object
146 |
# File 'lib/andromeda/impl/proto_plan.rb', line 146 def spot_attr_names ; self.class.spot_attr_names end |
#spot_meth_name?(name) ⇒ Boolean
142 |
# File 'lib/andromeda/impl/proto_plan.rb', line 142 def spot_meth_name?(name) ; spot_meth_names.include? name end |
#spot_meth_names ⇒ Object
147 |
# File 'lib/andromeda/impl/proto_plan.rb', line 147 def spot_meth_names ; self.class.spot_meth_names end |
#spot_name?(name) ⇒ Boolean
140 |
# File 'lib/andromeda/impl/proto_plan.rb', line 140 def spot_name?(name) ; spot_names.include? name end |
#spot_names ⇒ Object
145 |
# File 'lib/andromeda/impl/proto_plan.rb', line 145 def spot_names ; self.class.spot_names end |
#tags ⇒ Object
59 |
# File 'lib/andromeda/impl/proto_plan.rb', line 59 def ; @tags end |
#to_short_s ⇒ Object
60 |
# File 'lib/andromeda/impl/proto_plan.rb', line 60 def to_short_s ; " id=#{id.to_short_s}t" end |
#via(spot_name) ⇒ Object
162 |
# File 'lib/andromeda/impl/proto_plan.rb', line 162 def via(spot_name) ; entry.via(spot_name) end |