Class: Smullyan::Configuration
- Inherits:
-
Object
- Object
- Smullyan::Configuration
- Defined in:
- lib/smullyan/configuration.rb
Overview
Configuration for selecting combinator implementations
Instance Attribute Summary collapse
-
#use_direct_implementation ⇒ Object
Returns the value of attribute use_direct_implementation.
Instance Method Summary collapse
-
#direct?(combinator) ⇒ Boolean
Check if a combinator should use direct implementation.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#use_all_direct(value: true) ⇒ Object
Configure all combinators at once.
-
#use_direct(combinator, value: true) ⇒ Object
Configure specific combinators.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
10 11 12 13 14 15 16 17 18 |
# File 'lib/smullyan/configuration.rb', line 10 def initialize @use_direct_implementation = { b: false, # Bluebird c: false, # Cardinal w: false, # Warbler m: false, # Mockingbird l: false # Lark } end |
Instance Attribute Details
#use_direct_implementation ⇒ Object
Returns the value of attribute use_direct_implementation.
8 9 10 |
# File 'lib/smullyan/configuration.rb', line 8 def use_direct_implementation @use_direct_implementation end |
Instance Method Details
#direct?(combinator) ⇒ Boolean
Check if a combinator should use direct implementation
36 37 38 39 |
# File 'lib/smullyan/configuration.rb', line 36 def direct?(combinator) key = combinator.to_s.downcase.to_sym @use_direct_implementation[key] || false end |
#use_all_direct(value: true) ⇒ Object
Configure all combinators at once
29 30 31 32 33 |
# File 'lib/smullyan/configuration.rb', line 29 def use_all_direct(value: true) @use_direct_implementation.each_key do |key| @use_direct_implementation[key] = value end end |
#use_direct(combinator, value: true) ⇒ Object
Configure specific combinators
21 22 23 24 25 26 |
# File 'lib/smullyan/configuration.rb', line 21 def use_direct(combinator, value: true) key = combinator.to_s.downcase.to_sym raise ArgumentError, "Unknown combinator: #{combinator}" unless @use_direct_implementation.key?(key) @use_direct_implementation[key] = value end |