Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ProjectContainer
- # A self-updating container keeping track
- # of project data.
- class ProjectContainer
- attr_accessor :title
- attr_accessor :projects
- attr_accessor :rand_mode
- # Create variables and set title
- def initialize(title)
- @title = title
- @projects = []
- @item = 0
- end
- # update
- # Allows rand_mode as a test or runs the
- # production checking of projects.
- def update()
- if rand_mode
- @item = @item + 1
- projects << {
- name: "project#{@item}",
- progress: rand(0..100)
- }
- else
- puts "No data yet"
- end
- # send_data
- # Sends all current projects, which are
- # progress items, to the running dashboard.
- def send_data()
- send_event(
- 'progress_bars',
- {
- title: @title,
- progress_items: @projects
- }
- )
- end
- end
- projectContainer = ProjectContainer.new("Projects")
- SCHEDULER.every '10s' do
- projectContainer.update
- projectContainer.send_data
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement