Ruby solution with comments
Approach\nThanks to Vishal\'s solution and original reference.\n\n# Complexity\n- Time complexity:\n Add your time complexity here, e.g. O(n) \nO(n) -> n = leng
# Approach\nThanks to [Vishal\'s solution](https://leetcode.com/problems/number-of-unique-good-subsequences/solutions/1749583/java-simple-solution-o-n-with-detailed-explanation/) and original [reference](https://www.codingninjas.com/studio/library/number-of-unique-good-subsequences).\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(n) -> n = length of binary string\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(1)\n\n# Code\n```\n# @param {String} binary\n# @return {Integer}\ndef number_of_unique_good_subsequences(binary)\n    ends_with_one = 0\n    ends_with_zero = 0\n    has_zero = 0 # to factor in single subsequence \'0\'\n    mod = 10**9 + 7\n\n    binary.each_char do |char|\n        if char == \'1\'\n            # + 1 indicates we are considering it as a subsequnce for future characters. For example, fututre appends will be like, 10, 11, 101, 1101(where the first one is the constant one (+1) and remaining characters we are adding which are valid)\n            ends_with_one = (ends_with_one + ends_with_zero + 1) % mod\n        else\n            # no + 1 because we don\'t want to consider 0 as a separate subsequence. For example, any future appends to the substring will be 00, 01, 001, etc. (where the first zero is constant and remaining characters will be added but won\'t be valid based on given condition. Hence, no + 1)\n            ends_with_zero = (ends_with_one + ends_with_zero) % mod\n            has_zero = 1\n        end\n    end\n\n    (ends_with_one + ends_with_zero + has_zero) % mod\nend\n```
['Ruby']