Class: Appear::Revealers::BaseRevealer

Inherits:
Service show all
Defined in:
lib/appear/revealers.rb

Overview

extend to implement more revealers

Direct Known Subclasses

MacRevealer, Tmux

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseService

delegate, #initialize, require_service, required_services

Constructor Details

This class inherits a constructor from Appear::BaseService

Class Method Details

.register!Object

Register this class as a revealer so it will be called by Instance#call



53
54
55
# File 'lib/appear/revealers.rb', line 53

def self.register!
  Appear::REVEALERS.push(self)
end

Instance Method Details

#call(tree) ⇒ true?

Reveal ‘tree` if supported by this revealer. You can get a tree from Processes#process_tree.

Parameters:

Returns:

  • (true, nil)

    return true if we revealed something, otherwise nil



21
22
23
24
25
26
# File 'lib/appear/revealers.rb', line 21

def call(tree)
  target, *rest = tree
  if supports_tree?(target, rest)
    return reveal_tree(tree)
  end
end

#reveal_tree(tree) ⇒ true?

This method is abstract.

subclasses must implement this method.

Reveal ‘tree`. Should be implemented by subclasses.

Parameters:

Returns:

  • (true, nil)

    return true if we revealed something, otherwise nil



33
34
35
# File 'lib/appear/revealers.rb', line 33

def reveal_tree(tree)
  raise "not implemented"
end

#supports_tree?(target, rest) ⇒ Boolean

This method is abstract.

subclasses must implement this method.

Returns true if this revealer may be able to reveal something in the tree. For this method, the caller splits the tree into the target and the rest of the tree, which sometimes simplifies the implementation of this method.

Parameters:

Returns:

  • (Boolean)


47
48
49
# File 'lib/appear/revealers.rb', line 47

def supports_tree?(target, rest)
  raise "not implemented"
end