Class: BinData::Base
- Inherits:
-
Object
- Object
- BinData::Base
- Defined in:
- lib/binproxy/proxy_message.rb,
lib/binproxy/bindata.rb
Overview
Monkey-patch no-ops for state handling; user can override if needed. Note: can’t use nil as parameter value, so use empty string as placeholder.
Class Method Summary collapse
Instance Method Summary collapse
- #annotate_value(v) ⇒ Object
-
#annotated_snapshot ⇒ Object
Not called directly, but return value is merged by subclasses.
- #current_state ⇒ Object
- #summary ⇒ Object
- #update_state ⇒ Object
Class Method Details
.initial_state ⇒ Object
7 |
# File 'lib/binproxy/bindata.rb', line 7 def self.initial_state; ''; end |
Instance Method Details
#annotate_value(v) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/binproxy/proxy_message.rb', line 36 def annotate_value(v) if v.respond_to? :annotated_snapshot return v.annotated_snapshot end v = Base64.encode64(v) if v.is_a? String return { value: v } end |
#annotated_snapshot ⇒ Object
Not called directly, but return value is merged by subclasses
29 30 31 32 33 34 35 |
# File 'lib/binproxy/proxy_message.rb', line 29 def annotated_snapshot { name: nil, #things generally don't know their own name, so compound types will overwrite this. objclass: self.class.to_s, display: eval_parameter(:display_as) } end |
#current_state ⇒ Object
8 |
# File 'lib/binproxy/bindata.rb', line 8 def current_state; eval_parameter(:protocol_state) || @parent && @parent.current_state ; end |
#summary ⇒ Object
10 11 12 |
# File 'lib/binproxy/bindata.rb', line 10 def summary "#{self.class}: #{num_bytes} bytes of data" end |
#update_state ⇒ Object
9 |
# File 'lib/binproxy/bindata.rb', line 9 def update_state; current_state; end |