Class: Appear::Tmux::TmuxValue
- Inherits:
-
Util::ValueClass
- Object
- Util::ValueClass
- Appear::Tmux::TmuxValue
- Defined in:
- lib/appear/tmux.rb
Overview
Base value class for Tmux values. This class works in concert with the Tmux service to make a fluent Tmux API easy.
TmuxValues all have a reference to the Tmux service that created them, so that they can implement methods that proxy Tmux service interaction.
Class Method Summary collapse
-
.format_string ⇒ String
The format string we pass to Tmux when we expect a result of this class’s type.
-
.parse(tmux_hash, tmux) ⇒ Object
Parse a raw data has as returned by the Appear::Tmux service into an instance of this class.
-
.property(name, opts = {}) ⇒ Object
returns the type-coerced version of this field.
Instance Method Summary collapse
-
#tmux ⇒ Tmux
The tmux service that created this pane.
Methods inherited from Util::ValueClass
Constructor Details
This class inherits a constructor from Appear::Util::ValueClass
Class Method Details
.format_string ⇒ String
The format string we pass to Tmux when we expect a result of this class’s type. This format string should cause Tmux to return a value we can hand to selfself.parse
39 40 41 42 43 44 45 46 47 |
# File 'lib/appear/tmux.rb', line 39 def self.format_string result = "" @tmux_attrs.each do |var, opts| next unless opts[:tmux] part = ' ' + var.to_s + ':#{' + opts[:tmux].to_s + '}' result += part end result end |
.parse(tmux_hash, tmux) ⇒ Object
Parse a raw data has as returned by the Appear::Tmux service into an instance of this class.
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/appear/tmux.rb', line 54 def self.parse(tmux_hash, tmux) result = { :tmux => tmux } tmux_hash.each do |var, tmux_val| parser = @tmux_attrs[var][:parse] if parser result[var] = parser.to_proc.call(tmux_val) else result[var] = tmux_val end end self.new(result) end |
.property(name, opts = {}) ⇒ Object
returns the type-coerced version of this field. A symbol can be used, just like with usual block syntax.
28 29 30 31 32 |
# File 'lib/appear/tmux.rb', line 28 def self.property(name, opts = {}) var = super(name, opts) @tmux_attrs ||= {} @tmux_attrs[var] = opts if opts[:tmux] end |
Instance Method Details
#tmux ⇒ Tmux
Returns the tmux service that created this pane.
22 |
# File 'lib/appear/tmux.rb', line 22 property :tmux |