{"id":16019606,"url":"https://github.com/iboard/traffic_light","last_synced_at":"2025-07-26T10:37:54.669Z","repository":{"id":26375742,"uuid":"29825021","full_name":"iboard/traffic_light","owner":"iboard","description":"A trafffic-light controller using ruby, fibers, and curses","archived":false,"fork":false,"pushed_at":"2015-09-26T11:45:43.000Z","size":196,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-24T03:56:09.101Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iboard.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-01-25T18:24:17.000Z","updated_at":"2015-04-04T09:24:19.000Z","dependencies_parsed_at":"2022-09-25T04:50:34.724Z","dependency_job_id":null,"html_url":"https://github.com/iboard/traffic_light","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/iboard/traffic_light","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iboard%2Ftraffic_light","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iboard%2Ftraffic_light/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iboard%2Ftraffic_light/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iboard%2Ftraffic_light/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iboard","download_url":"https://codeload.github.com/iboard/traffic_light/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iboard%2Ftraffic_light/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267150480,"owners_count":24043473,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-26T02:00:08.937Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-08T17:04:54.267Z","updated_at":"2025-07-26T10:37:54.644Z","avatar_url":"https://github.com/iboard.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Traffic Light Controller\n\nA trafffic-light controller using Ruby, Fibers, and Curses\n\n## Run it\n\n  1. git clone https://github.com/iboard/traffic_light.git\n  2. cd traffic_light\n  3. bundle\n  4. ./traffic_light\n\n## Source\n\n### Define a light-group\n\n  1. Define a 'light-group' within the light_groups hash in\n  `traffic_light.rb` as a symbol.\n  2. Define a method in presenter.rb with the same name which is\n  responsible to draw that light-group on the `Display`\n\n### Understanding\n\n  * The 'Matrix' is defined as an array of 'state-lines'\n  * a 'state-line' is an array with the number of ticks this state holds\n    in the first column followed by a string for each light-group.\n\n                | Ticks G1  G2    G3 G4   G5     G6\n        --------+-----------------------------------------------------\n        State 1 |   8  --R  STOP  -  G--  -GO-   on-east-west\n        State 2 |   2  --R  STOP  X  *--  #GO#   on-stopping-east-west\n        State 3 |   2  --R  STOP  X  -O-  STOP   on-stopping-east-west\n        State 4 |   4  --R  STOP  X  --R  STOP   on-all-stopped\n\n  * `Board` initializes an array of `Fiber`s (one for each light-group)\n  * Each of this Fibers yields to `TrafficLight.state()`\n  * A call to `board.tick()` calls `resume` on each of the Fibers\n  * The state of a fiber holds the array of states of a light-group\n    and the 'current' position.\n  * On each `resume` a fiber shifts the current position and resets it\n    on overflow.\n  * The `Presenter` knows how to draw the elements (lights, lanes, ...)\n    using a `Display` for the low level drawing with `Curses`\n\nHave Fun!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiboard%2Ftraffic_light","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiboard%2Ftraffic_light","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiboard%2Ftraffic_light/lists"}