Advertisement
Guest User

Untitled

a guest
Jul 6th, 2015
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. # ProjectContainer
  2. # A self-updating container keeping track
  3. # of project data.
  4. class ProjectContainer
  5.  
  6. attr_accessor :title
  7. attr_accessor :projects
  8.  
  9. attr_accessor :rand_mode
  10.  
  11. # Create variables and set title
  12. def initialize(title)
  13. @title = title
  14. @projects = []
  15. @item = 0
  16. end
  17.  
  18. # update
  19. # Allows rand_mode as a test or runs the
  20. # production checking of projects.
  21. def update()
  22.  
  23. if rand_mode
  24. @item = @item + 1
  25.  
  26. projects << {
  27. name: "project#{@item}",
  28. progress: rand(0..100)
  29. }
  30. else
  31. puts "No data yet"
  32.  
  33. end
  34.  
  35. # send_data
  36. # Sends all current projects, which are
  37. # progress items, to the running dashboard.
  38. def send_data()
  39. send_event(
  40. 'progress_bars',
  41. {
  42. title: @title,
  43. progress_items: @projects
  44. }
  45. )
  46. end
  47.  
  48. end
  49.  
  50. projectContainer = ProjectContainer.new("Projects")
  51.  
  52. SCHEDULER.every '10s' do
  53. projectContainer.update
  54. projectContainer.send_data
  55. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement