Class: Adjective::Table::Experience
- Inherits:
-
Adjective::Table
- Object
- Adjective::Table
- Adjective::Table::Experience
- Defined in:
- lib/adjective/table.rb
Overview
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # Will separate out when I get the dir structures set up properly. # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Instance Attribute Summary collapse
-
#thresholds ⇒ Object
readonly
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.
Attributes inherited from Adjective::Table
Instance Method Summary collapse
- #at_level(level) ⇒ Object
-
#initialize(dir, name = nil) ⇒ Experience
constructor
A new instance of Experience.
Methods inherited from Adjective::Table
Constructor Details
#initialize(dir, name = nil) ⇒ Experience
Returns a new instance of Experience.
45 46 47 48 49 50 51 52 53 54 55 |
# 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 |
Instance Attribute Details
#thresholds ⇒ Object (readonly)
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.
43 44 45 |
# File 'lib/adjective/table.rb', line 43 def thresholds @thresholds end |
Instance Method Details
#at_level(level) ⇒ Object
57 58 59 60 61 62 63 64 |
# 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 |