Class: Bcome::RenderIrb

Inherits:
Object show all
Defined in:
lib/render_irb.rb

Instance Method Summary collapse

Instance Method Details

#construct_menu_item_string(item, index, colour) ⇒ Object



38
39
40
41
42
43
44
45
46
47
# File 'lib/render_irb.rb', line 38

def construct_menu_item_string(item, index, colour)
  command = item[:command]
  description = item[:description]
  usage = item[:usage]
  menu_str = "#{tab}#{index+1}. #{description}".send(colour) + "\n"
  menu_str += "#{tab}" + "Command: ".menu_item_cyan + "#{command}\n".menu_item_white
  menu_str += "#{tab}" + "Usage: ".menu_item_cyan + "#{usage}\n".menu_item_white if usage
  menu_str += "\n"
  return menu_str
end

#list_items(parent_collection, items) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/render_irb.rb', line 3

def list_items(parent_collection, items)
  if !items || !items.any?
    print "\n\sNo resources collections found. Maybe you forgot to add any?".headsup
  else
   print "\n\s"
   puts "#{parent_collection.to_s.menu_title_green}\n".menu_title_green
   items.each do |item|
      puts "\t*/added".danger + "\n" if item.highlight?
      print item.do_describe
    end
    print "\n\s\sUse cd [node identifier], e.g. cd :#{items.first.identifier} OR cd \"#{items.first.identifier}\" to work on a given node.\n\n"
  end
end


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/render_irb.rb', line 17

def menu(menu_items, stack_level_instance)
  menu_str = "\n\s#{"Basic Commands".menu_title_green}\n\n"
  menu_items.each_with_index do |item, index|
    menu_str += construct_menu_item_string(item, index, :menu_item_green)
  end

  recipe_menu_items = ::Bcome::Orchestrator::Recipe.as_menu_items(stack_level_instance)    
  if recipe_menu_items.any?  
    menu_str += "\n\s#{"Orchestration Menu".menu_title_orange}\n\n"   
    recipe_menu_items.each_with_index do |item, index|
      menu_str += construct_menu_item_string(item, index, :menu_item_orange)
    end 
  end

  menu_str += stack_level_instance.context_commands if stack_level_instance.context_commands

  menu_str += "\n\n"
  print menu_str
  return
end

#tabObject



49
50
51
# File 'lib/render_irb.rb', line 49

def tab
  "\s\s\s"
end