Module: Plushie::Protocol::Parsers
- Defined in:
- lib/plushie/protocol/parsers.rb
Overview
Shared string-to-symbol parsers used by the decode layer.
These convert wire-format strings into Ruby symbols for pattern matching in user code.
Constant Summary collapse
- MOUSE_BUTTONS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Mouse button name mapping.
{ "left" => :left, "right" => :right, "middle" => :middle, "back" => :back, "forward" => :forward }.freeze
Class Method Summary collapse
-
.parse_mouse_button(str) ⇒ Symbol, ...
Parse a mouse button string to a symbol.
-
.parse_pane_action(str) ⇒ Symbol?
Parse a pane drag action string to a symbol.
-
.parse_pane_region(str) ⇒ Symbol?
Parse a pane region/edge string to a symbol.
-
.parse_scroll_unit(str) ⇒ Symbol?
Parse a scroll unit string to a symbol.
Class Method Details
.parse_mouse_button(str) ⇒ Symbol, ...
Parse a mouse button string to a symbol.
23 24 25 26 |
# File 'lib/plushie/protocol/parsers.rb', line 23 def (str) return nil if str.nil? MOUSE_BUTTONS.fetch(str, str) end |
.parse_pane_action(str) ⇒ Symbol?
Parse a pane drag action string to a symbol.
43 44 45 46 47 48 49 |
# File 'lib/plushie/protocol/parsers.rb', line 43 def parse_pane_action(str) case str when "picked" then :picked when "dropped" then :dropped when "canceled" then :canceled end end |
.parse_pane_region(str) ⇒ Symbol?
Parse a pane region/edge string to a symbol.
55 56 57 58 59 60 61 62 63 |
# File 'lib/plushie/protocol/parsers.rb', line 55 def parse_pane_region(str) case str when "center" then :center when "top" then :top when "bottom" then :bottom when "left" then :left when "right" then :right end end |
.parse_scroll_unit(str) ⇒ Symbol?
Parse a scroll unit string to a symbol.
32 33 34 35 36 37 |
# File 'lib/plushie/protocol/parsers.rb', line 32 def parse_scroll_unit(str) case str when "line", "lines" then :line when "pixel", "pixels" then :pixel end end |