Class: Table
- Inherits:
-
Object
- Object
- Table
- Defined in:
- lib/table.rb
Class Method Summary collapse
-
.maps(maps, currentMap) ⇒ Object
Print the maps table.
- .road(road, roadID, allStaff) ⇒ Object
- .roads(roads, currentMap) ⇒ Object
- .status ⇒ Object
Class Method Details
.maps(maps, currentMap) ⇒ Object
Print the maps table
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/table.rb', line 6 def self.maps(maps, currentMap) user_table = table do |t| t.headings = 'ID', 'Title' maps.each_pair do |key, roadmap| t << [key ,roadmap["title"]] end end puts "\n" puts user_table begin puts "Current " + "#{currentMap}".bright.background(:blue) + " >> " + "#{maps[currentMap]["title"]}".bright rescue puts "None selected.".bright.color(:yellow) end puts "\n" end |
.road(road, roadID, allStaff) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/table.rb', line 40 def self.road(road, roadID, allStaff) puts "\n" puts "#{roadID.bright} >> ".background(:blue) + "#{road["title"]}".bright puts "#{road["description"]}" puts "#{road["status"]["status"]}".bright updates = road["updates"] if updates.count > 0 user_table = table do |t| t.headings = 'Staff', 'Message', 'Time' updates.each do |update| staff = allStaff["#{update["staffId"]}"] time = Time.at(update["time"]) t << ["#{staff}", "#{update["update"]}", time.ago_in_words] end end puts "\n" puts user_table puts "\n" else puts "\n" puts "No Updates" puts "\n" end end |
.roads(roads, currentMap) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/table.rb', line 23 def self.roads(roads, currentMap) begin user_table = table do |t| t.headings = 'ID', 'Title', 'Route', 'Description' roads.each_pair do |shortcode, road| t << [shortcode ,road["title"], road["route"], "#{road["description"][0, 100]}..."] end end puts "\n" puts "Roads for #{currentMap}".bright puts user_table puts "\n" rescue puts "Could not get roads" end end |
.status ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/table.rb', line 67 def self.status() statuses = ["Stopped", "Started", "10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "Ready", "Launched", "Proposed", "Postponed"] user_table = table do |t| t.headings = "Status", "Code" statuses.each_with_index do |value, index| t << [value, index] end end puts "\n" puts user_table puts "\n" end |