Class: Preflight::Rules::MatchInfoEntries
- Inherits:
-
Object
- Object
- Preflight::Rules::MatchInfoEntries
- Defined in:
- lib/preflight/rules/match_info_entries.rb
Instance Method Summary collapse
-
#initialize(matches = {}) ⇒ MatchInfoEntries
constructor
A new instance of MatchInfoEntries.
- #messages(ohash) ⇒ Object
Constructor Details
#initialize(matches = {}) ⇒ MatchInfoEntries
Returns a new instance of MatchInfoEntries.
7 8 9 |
# File 'lib/preflight/rules/match_info_entries.rb', line 7 def initialize(matches = {}) @matches = matches end |
Instance Method Details
#messages(ohash) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/preflight/rules/match_info_entries.rb', line 11 def (ohash) array = [] info = ohash.object(ohash.trailer[:Info]) @matches.each do |key, regexp| if !info.has_key?(key) array << "Info dict missing required key #{key}" elsif !info[key].to_s.match(regexp) array << "value of Info entry #{key} doesn't match (#{info[key]} != #{regexp})" end end array end |