Class: Uniword::Accessibility::AccessibilityProfile
- Inherits:
-
Object
- Object
- Uniword::Accessibility::AccessibilityProfile
- Defined in:
- lib/uniword/accessibility/accessibility_profile.rb
Overview
Accessibility Profile - configuration for accessibility checking profile
Responsibility: Load and manage profile configuration Single Responsibility: Profile configuration management only
Instance Attribute Summary collapse
-
#inherits ⇒ Object
readonly
Returns the value of attribute inherits.
-
#level ⇒ Object
readonly
Returns the value of attribute level.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#overrides ⇒ Object
readonly
Returns the value of attribute overrides.
-
#rules ⇒ Object
readonly
Returns the value of attribute rules.
Class Method Summary collapse
-
.load(config, profile_name) ⇒ AccessibilityProfile
Load a profile from configuration.
Instance Method Summary collapse
-
#initialize(config, all_profiles = {}) ⇒ AccessibilityProfile
constructor
Initialize a new accessibility profile.
-
#rule_config(rule_name) ⇒ Hash?
Get configuration for a specific rule.
-
#rule_enabled?(rule_name) ⇒ Boolean
Check if a rule is enabled.
Constructor Details
#initialize(config, all_profiles = {}) ⇒ AccessibilityProfile
Initialize a new accessibility profile
42 43 44 45 46 47 48 49 50 |
# File 'lib/uniword/accessibility/accessibility_profile.rb', line 42 def initialize(config, all_profiles = {}) @config = config @all_profiles = all_profiles @name = config[:name] || config["name"] @level = config[:level] || config["level"] @inherits = config[:inherits] || config["inherits"] @overrides = config[:overrides] || config["overrides"] || {} @rules = build_rules_config end |
Instance Attribute Details
#inherits ⇒ Object (readonly)
Returns the value of attribute inherits.
14 15 16 |
# File 'lib/uniword/accessibility/accessibility_profile.rb', line 14 def inherits @inherits end |
#level ⇒ Object (readonly)
Returns the value of attribute level.
14 15 16 |
# File 'lib/uniword/accessibility/accessibility_profile.rb', line 14 def level @level end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
14 15 16 |
# File 'lib/uniword/accessibility/accessibility_profile.rb', line 14 def name @name end |
#overrides ⇒ Object (readonly)
Returns the value of attribute overrides.
14 15 16 |
# File 'lib/uniword/accessibility/accessibility_profile.rb', line 14 def overrides @overrides end |
#rules ⇒ Object (readonly)
Returns the value of attribute rules.
14 15 16 |
# File 'lib/uniword/accessibility/accessibility_profile.rb', line 14 def rules @rules end |
Class Method Details
.load(config, profile_name) ⇒ AccessibilityProfile
Load a profile from configuration
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/uniword/accessibility/accessibility_profile.rb', line 22 def self.load(config, profile_name) profiles_config = config[:profiles] || config["profiles"] unless profiles_config raise ArgumentError, "No profiles found in configuration" end profile_config = profiles_config[profile_name] || profiles_config[profile_name.to_s] unless profile_config raise ArgumentError, "Profile '#{profile_name}' not found" end new(profile_config, profiles_config) end |
Instance Method Details
#rule_config(rule_name) ⇒ Hash?
Get configuration for a specific rule
56 57 58 |
# File 'lib/uniword/accessibility/accessibility_profile.rb', line 56 def rule_config(rule_name) @rules[rule_name.to_sym] || @rules[rule_name.to_s] end |
#rule_enabled?(rule_name) ⇒ Boolean
Check if a rule is enabled
64 65 66 67 68 69 |
# File 'lib/uniword/accessibility/accessibility_profile.rb', line 64 def rule_enabled?(rule_name) config = rule_config(rule_name) return false unless config config.fetch(:enabled, config.fetch("enabled", true)) end |