Class: Alfred::Handler::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/alfred/handler.rb

Direct Known Subclasses

Autocomplete, Callback, Config, Help

Constant Summary collapse

Base_Invoke_Order =
100

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(alfred, opts = {}) ⇒ Base

Returns a new instance of Base.



14
15
16
17
18
# File 'lib/alfred/handler.rb', line 14

def initialize(alfred, opts = {})
  @core = alfred
  @order = Base_Invoke_Order
  @status = :initialize
end

Instance Attribute Details

#orderObject (readonly)

Returns the value of attribute order.



12
13
14
# File 'lib/alfred/handler.rb', line 12

def order
  @order
end

#statusObject (readonly)

Returns the value of attribute status.



12
13
14
# File 'lib/alfred/handler.rb', line 12

def status
  @status
end

Instance Method Details

#<=>(other) ⇒ Object



52
53
54
# File 'lib/alfred/handler.rb', line 52

def <=>(other)
  order <=> other.order
end

#action?(arg) ⇒ Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/alfred/handler.rb', line 36

def action?(arg)
  arg.is_a?(Hash) && arg[:handler].eql?(@settings[:handler])
end

#feedbackObject



87
88
89
# File 'lib/alfred/handler.rb', line 87

def feedback
  @core.feedback
end

#feedback?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/alfred/handler.rb', line 29

def feedback?
  true
end

#on_action(arg) ⇒ Object



40
41
42
# File 'lib/alfred/handler.rb', line 40

def on_action(arg)
  ;
end

#on_closeObject



44
45
46
# File 'lib/alfred/handler.rb', line 44

def on_close
  ;
end

#on_feedbackObject

Raises:

  • (NotImplementedError)


32
33
34
# File 'lib/alfred/handler.rb', line 32

def on_feedback
  raise NotImplementedError
end

#on_helpObject



25
26
27
# File 'lib/alfred/handler.rb', line 25

def on_help
  []
end

#on_parserObject



21
22
23
# File 'lib/alfred/handler.rb', line 21

def on_parser
  ;
end

#optionsObject



71
72
73
# File 'lib/alfred/handler.rb', line 71

def options
  @core.options
end

#parserObject



75
76
77
# File 'lib/alfred/handler.rb', line 75

def parser
  @core.query_parser
end

#queryObject



79
80
81
# File 'lib/alfred/handler.rb', line 79

def query
  @core.query
end

#registerObject



48
49
50
# File 'lib/alfred/handler.rb', line 48

def register
  @core.handler_controller.register(self)
end

#status_message(text, exitstatus) ⇒ Object



57
58
59
60
61
62
63
# File 'lib/alfred/handler.rb', line 57

def status_message(text, exitstatus)
  if exitstatus == 0
    return "#{text}"
  else
    return "#{text}"
  end
end

#uiObject



83
84
85
# File 'lib/alfred/handler.rb', line 83

def ui
  @core.ui
end

#xml_builder(arg) ⇒ Object

from alfred core



67
68
69
# File 'lib/alfred/handler.rb', line 67

def xml_builder(arg)
  @core.xml_builder(arg)
end