class ConlangWordGenerator::Maybe
Public Class Methods
new(weight, set)
click to toggle source
# File lib/conlang/operators.rb, line 67 def initialize(weight, set) unless weight > 0 and weight < 100 raise LangSyntaxError, "Weight for an maybe() operator " + "must be between 1 and 100 (exclusive)." end @weight = weight @set = set end
Public Instance Methods
+(other)
click to toggle source
# File lib/conlang/operators.rb, line 85 def +(other) Append.new(self, other) end
sample()
click to toggle source
# File lib/conlang/operators.rb, line 77 def sample if rand(100) < @weight @set.sample else "" end end