Class: Switch
- Inherits:
-
Object
- Object
- Switch
- Defined in:
- lib/shopifydev/pry/commands.rb
Instance Method Summary collapse
- #current_shop ⇒ Object
- #finish! ⇒ Object
- #finished? ⇒ Boolean
-
#initialize ⇒ Switch
constructor
A new instance of Switch.
- #menu ⇒ Object
- #pick(ix) ⇒ Object
- #reset! ⇒ Object
Constructor Details
#initialize ⇒ Switch
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_shop ⇒ Object
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
20 21 22 |
# File 'lib/shopifydev/pry/commands.rb', line 20 def finished? @finished end |
#menu ⇒ Object
28 29 30 |
# File 'lib/shopifydev/pry/commands.rb', line 28 def @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..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 = @finished = false end |