Class: Switch

Inherits:
Object
  • Object
show all
Defined in:
lib/shopifydev/pry/commands.rb

Instance Method Summary collapse

Constructor Details

#initializeSwitch

Returns a new instance of Switch.



5
6
7
8
# File 'lib/shopifydev/pry/commands.rb', line 5

def initialize
  @current_shop = ''
  reset!
end

Instance Method Details

#current_shopObject



10
11
12
13
# File 'lib/shopifydev/pry/commands.rb', line 10

def current_shop
  @current_shop = ShopifyAPI::Base.site || 'none'
  TColor.green{ "current shop:"} + " #{@current_shop}"
end

#finish!Object



24
25
26
# File 'lib/shopifydev/pry/commands.rb', line 24

def finish!
  @finished = true
end

#finished?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/shopifydev/pry/commands.rb', line 20

def finished?
  @finished
end


28
29
30
# File 'lib/shopifydev/pry/commands.rb', line 28

def menu
  @menu
end

#pick(ix) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/shopifydev/pry/commands.rb', line 32

def pick(ix)
  result = ''

  # TODO we need need need to rename cfg, as it is currently confusing
  @breadcrumbs, @cfg = pick_config(ix)

  if @breadcrumbs == :no_such_config
    result << TColor.red{ "I don't know about #{ix}\n" }
    result << self.menu.print
  else
    # update the menu based on the choice
    # if we've reached a terminal menu, then do something
    # otherwise just present the next menu
    result << handle_choice
  end
end

#reset!Object



15
16
17
18
# File 'lib/shopifydev/pry/commands.rb', line 15

def reset!
  @menu = default_menu
  @finished = false
end