Class: VER::Keymap::Results::Incomplete

Inherits:
Struct
  • Object
show all
Defined in:
lib/ver/keymap.rb

Overview

Indicate that no result could be found yet.

Constant Summary

Constants inherited from Struct

Struct::CACHE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Struct

new

Instance Attribute Details

#choicesObject

Returns the value of attribute choices

Returns:

  • (Object)

    the current value of choices



15
16
17
# File 'lib/ver/keymap.rb', line 15

def choices
  @choices
end

#patternObject

Returns the value of attribute pattern

Returns:

  • (Object)

    the current value of pattern



15
16
17
# File 'lib/ver/keymap.rb', line 15

def pattern
  @pattern
end

Instance Method Details

#merge!(incomplete) ⇒ Object



16
17
18
19
# File 'lib/ver/keymap.rb', line 16

def merge!(incomplete)
  return unless pattern == incomplete.pattern
  choices.deep_merge!(incomplete.choices)
end

#to_s(handler) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/ver/keymap.rb', line 21

def to_s(handler)
  stack = pattern.map{|seq| Event[seq].keysym }.join

  follow = choices.map{|key, action|
    case action
    when Action
      method = action.to_method(handler)
      args = [*action.invocation][1..-1]

      case receiver = method.receiver
      when Class, Module
        signature = "#{receiver}.#{method.name}"
      else
        signature = "#{method.receiver.class}.#{method.name}"
      end

      unless args.empty?
        signature << '(' << args.map(&:inspect).join(', ') << ')'
      end

      "#{key} => #{signature}"
    when MapHash
      key
    else
      '%s => %p' % [key, action]
    end
  }.join(', ')
  "#{stack} -- (#{follow})"
end