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.



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

def initialize
  @current_shop = ''
  reset!
end

Instance Method Details

#current_shopObject



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

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

#finish!Object



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

def finish!
  @finished = true
end

#finished?Boolean

Returns:

  • (Boolean)


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

def finished?
  @finished
end


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

def menu
  @menu
end

#pick(ix) ⇒ Object



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

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



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

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