class DiceBag::Result

This class merely encapsulates the result, providing convience methods to access the results of each section if desired.

Attributes

label[R]
sections[R]
total[R]

Public Class Methods

new(label, total, sections) click to toggle source
# File lib/dicebag/result.rb, line 12
def initialize(label, total, sections)
  @label    = label
  @total    = total
  @sections = sections
end

Public Instance Methods

each() { |section| ... } click to toggle source
# File lib/dicebag/result.rb, line 18
def each
  sections.each { |section| yield section }
end
to_s() click to toggle source
# File lib/dicebag/result.rb, line 22
def to_s
  return "#{label}: #{total}" unless label.empty?

  total.to_s
end