Class: SleepingKingStudios::Tools::Toolbelt
- Inherits:
- BasicObject
- Defined in:
- lib/sleeping_king_studios/tools/toolbelt.rb
Overview
Helper object for quick access to all available tools.
Specific tools can be accessed by name. For example, to access the configured instance of ArrayTools, call Toolbelt#array_tools. Certain tools also define a shorthand - for example, the array_tools instance can also be accessed using Toolbelt#ary.
Class Method Summary collapse
-
.global ⇒ Registry
(also: instance)
Returns a singleton instance of the messages registry, instantiating the instance if needed.
Instance Method Summary collapse
-
#array_tools ⇒ SleepingKingStudios::Tools::ArrayTools
(also: #ary)
Tools for working with array-like enumerable objects.
-
#assertions ⇒ SleepingKingStudios::Tools::Assertions
Methods for asserting on the state of a function or application.
-
#core_tools ⇒ SleepingKingStudios::Tools::CoreTools
Tools for working with an application or working environment.
-
#hash_tools ⇒ SleepingKingStudios::Tools::HashTools
(also: #hsh)
Tools for working with hash-like enumerable objects.
-
#initialize(deprecation_caller_depth: nil, deprecation_strategy: nil, inflector: nil, messages_registry: nil) ⇒ Toolbelt
constructor
A new instance of Toolbelt.
-
#inspect ⇒ String
(also: #to_s)
A human-readable representation of the object.
-
#integer_tools ⇒ SleepingKingStudios::Tools::IntegerTools
(also: #int)
Tools for working with integers.
-
#messages ⇒ SleepingKingStudios::Tools::Messages
Methods for generating human-readable messages.
-
#object_tools ⇒ SleepingKingStudios::Tools::ObjectTools
(also: #obj)
Low-level tools for working with objects.
-
#string_tools ⇒ SleepingKingStudios::Tools::ObjectTools
(also: #str)
Tools for working with strings.
Constructor Details
#initialize(deprecation_caller_depth: nil, deprecation_strategy: nil, inflector: nil, messages_registry: nil) ⇒ Toolbelt
Returns a new instance of Toolbelt.
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/sleeping_king_studios/tools/toolbelt.rb', line 44 def initialize( deprecation_caller_depth: nil, deprecation_strategy: nil, inflector: nil, messages_registry: nil ) @deprecation_caller_depth = deprecation_caller_depth @deprecation_strategy = deprecation_strategy @inflector = inflector @messages_registry = end |
Class Method Details
.global ⇒ Registry Also known as: instance
Returns a singleton instance of the messages registry, instantiating the instance if needed.
27 28 29 |
# File 'lib/sleeping_king_studios/tools/toolbelt.rb', line 27 define_method :global do semaphore.synchronize { @global ||= new } end |
Instance Method Details
#array_tools ⇒ SleepingKingStudios::Tools::ArrayTools Also known as: ary
Returns tools for working with array-like enumerable objects.
58 59 60 |
# File 'lib/sleeping_king_studios/tools/toolbelt.rb', line 58 def array_tools @array_tools ||= ::SleepingKingStudios::Tools::ArrayTools.new(toolbelt:) end |
#assertions ⇒ SleepingKingStudios::Tools::Assertions
Returns methods for asserting on the state of a function or application.
65 66 67 |
# File 'lib/sleeping_king_studios/tools/toolbelt.rb', line 65 def assertions @assertions ||= ::SleepingKingStudios::Tools::Assertions.new(toolbelt:) end |
#core_tools ⇒ SleepingKingStudios::Tools::CoreTools
Returns tools for working with an application or working environment.
71 72 73 74 75 76 77 |
# File 'lib/sleeping_king_studios/tools/toolbelt.rb', line 71 def core_tools @core_tools ||= ::SleepingKingStudios::Tools::CoreTools.new( deprecation_caller_depth:, deprecation_strategy:, toolbelt: ) end |
#hash_tools ⇒ SleepingKingStudios::Tools::HashTools Also known as: hsh
Returns tools for working with hash-like enumerable objects.
81 82 83 |
# File 'lib/sleeping_king_studios/tools/toolbelt.rb', line 81 def hash_tools @hash_tools ||= ::SleepingKingStudios::Tools::HashTools.new(toolbelt:) end |
#inspect ⇒ String Also known as: to_s
Returns a human-readable representation of the object.
87 88 89 |
# File 'lib/sleeping_king_studios/tools/toolbelt.rb', line 87 def inspect "#<#{::Object.instance_method(:class).bind(self).call.name}>" end |
#integer_tools ⇒ SleepingKingStudios::Tools::IntegerTools Also known as: int
Returns tools for working with integers.
94 95 96 |
# File 'lib/sleeping_king_studios/tools/toolbelt.rb', line 94 def integer_tools @integer_tools = ::SleepingKingStudios::Tools::IntegerTools.new(toolbelt:) end |
#messages ⇒ SleepingKingStudios::Tools::Messages
Returns methods for generating human-readable messages.
101 102 103 104 105 106 |
# File 'lib/sleeping_king_studios/tools/toolbelt.rb', line 101 def @messages ||= ::SleepingKingStudios::Tools::Messages.new( registry: , toolbelt: ) end |
#object_tools ⇒ SleepingKingStudios::Tools::ObjectTools Also known as: obj
Returns low-level tools for working with objects.
110 111 112 |
# File 'lib/sleeping_king_studios/tools/toolbelt.rb', line 110 def object_tools @object_tools ||= ::SleepingKingStudios::Tools::ObjectTools.new(toolbelt:) end |
#string_tools ⇒ SleepingKingStudios::Tools::ObjectTools Also known as: str
Returns tools for working with strings.
117 118 119 120 121 122 |
# File 'lib/sleeping_king_studios/tools/toolbelt.rb', line 117 def string_tools @string_tools ||= ::SleepingKingStudios::Tools::StringTools.new( inflector:, toolbelt: ) end |