class Adjective::Table::Experience
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # Will separate out when I get the dir structures set up properly. # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Attributes
thresholds[R]
This is primarily to keep the access points standardized and would only require someone consuming the library to call something like level.to_i to maintain the convention.
Public Class Methods
new(dir, name = nil)
click to toggle source
Calls superclass method
Adjective::Table::new
# File lib/adjective/table.rb, line 45 def initialize(dir, name = nil) # raise ArgumentError super(dir, name) @thresholds = @data[@name] if !@thresholds.is_a?(Array) raise RuntimeError, "#{Time.now}]: Experience table '#{@name}' is not an Array: #{@exp_thresholds.class}" elsif threshold_sorted? raise RuntimeError, "#{Time.now}]: Experience table '#{@name}' is not sequential: #{@exp_thresholds}" end end
Public Instance Methods
at_level(level)
click to toggle source
# File lib/adjective/table.rb, line 57 def at_level(level) # Convenience methods to translate string cases might be worth it... but the # general convention is that you pass through whole integers to grab data that is # more reliable within the structure of the code itself. Going to just keep to # convention for the moment. raise RuntimeError, "#{Time.now}]: Level provided is not an Integer: #{level}" if !level.is_a?(Integer) return @thresholds[level] end
Private Instance Methods
threshold_sorted?()
click to toggle source
# File lib/adjective/table.rb, line 68 def threshold_sorted? @thresholds != @thresholds.sort end