Class: WarningSigns::OnlyExcept
- Inherits:
-
Object
- Object
- WarningSigns::OnlyExcept
- Defined in:
- lib/warning_signs/only_except.rb
Instance Attribute Summary collapse
-
#except ⇒ Object
Returns the value of attribute except.
-
#only ⇒ Object
Returns the value of attribute only.
Instance Method Summary collapse
- #except_match?(message) ⇒ Boolean
-
#initialize(only: [], except: []) ⇒ OnlyExcept
constructor
A new instance of OnlyExcept.
- #only_except_match?(message) ⇒ Boolean
- #only_match?(message) ⇒ Boolean
- #valid? ⇒ Boolean
Constructor Details
#initialize(only: [], except: []) ⇒ OnlyExcept
Returns a new instance of OnlyExcept.
5 6 7 8 |
# File 'lib/warning_signs/only_except.rb', line 5 def initialize(only: [], except: []) @only = only @except = except end |
Instance Attribute Details
#except ⇒ Object
Returns the value of attribute except.
3 4 5 |
# File 'lib/warning_signs/only_except.rb', line 3 def except @except end |
#only ⇒ Object
Returns the value of attribute only.
3 4 5 |
# File 'lib/warning_signs/only_except.rb', line 3 def only @only end |
Instance Method Details
#except_match?(message) ⇒ Boolean
21 22 23 24 25 26 |
# File 'lib/warning_signs/only_except.rb', line 21 def except_match?() return true if except.empty? except.none? do |except_pattern| except_pattern.match?() end end |
#only_except_match?(message) ⇒ Boolean
10 11 12 |
# File 'lib/warning_signs/only_except.rb', line 10 def only_except_match?() only_match?() && except_match?() end |
#only_match?(message) ⇒ Boolean
14 15 16 17 18 19 |
# File 'lib/warning_signs/only_except.rb', line 14 def only_match?() return true if only.empty? only.any? do |only_pattern| only_pattern.match?() end end |
#valid? ⇒ Boolean
28 29 30 |
# File 'lib/warning_signs/only_except.rb', line 28 def valid? except.empty? || only.empty? end |