class RpgLib::RollSet
Attributes
rolls[R]
Public Class Methods
new(*args)
click to toggle source
# File lib/rpg_lib/roll_set.rb, line 27 def initialize(*args) @rolls = Set.new args.each { |a| add(a) } end
Public Instance Methods
add(r)
click to toggle source
# File lib/rpg_lib/roll_set.rb, line 40 def add(r) if r.is_a?(Integer) @rolls.add(r) elsif r.is_a?(Range) r.to_a.map { |e| @rolls.add(e) } elsif r.is_a?(RollSet) @rolls.merge(r.rolls) else raise Exception, "Invalid type (#{r.class}) added to roll set" end end
empty?()
click to toggle source
# File lib/rpg_lib/roll_set.rb, line 32 def empty? @rolls.empty? end
include?(roll)
click to toggle source
# File lib/rpg_lib/roll_set.rb, line 36 def include?(roll) @rolls.include?(roll) end
to_s()
click to toggle source
# File lib/rpg_lib/roll_set.rb, line 52 def to_s @rolls.to_a.join(', ') end