class ConlangWordGenerator::Or
Classes for operators and operands.
Public Class Methods
new(weight, setA, setB)
click to toggle source
# File lib/conlang/operators.rb, line 24 def initialize(weight, setA, setB) unless weight > 0 and weight < 100 raise LangSyntaxError, "Weight for an or() operator must " + "be between 1 and 100 (exclusive)." end @weight = weight @setA = setA @setB = setB end
Public Instance Methods
+(other)
click to toggle source
# File lib/conlang/operators.rb, line 43 def +(other) Append.new(self, other) end
sample()
click to toggle source
# File lib/conlang/operators.rb, line 35 def sample if rand(100) < @weight @setA.sample else @setB.sample end end