Class: Mulang::Inspection::Matcher
- Inherits:
-
Object
- Object
- Mulang::Inspection::Matcher
- Includes:
- Compacted
- Defined in:
- lib/mulang/inspection/matcher.rb
Constant Summary collapse
- TYPES =
%w(WithChar WithFalse WithLiteral WithLogic WithMath WithNil WithNonliteral WithNumber WithString WithSymbol WithTrue)
Instance Attribute Summary collapse
-
#type ⇒ Object
Returns the value of attribute type.
-
#value ⇒ Object
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(type, value = nil) ⇒ Matcher
constructor
A new instance of Matcher.
- #to_s ⇒ Object
Methods included from Compacted
Constructor Details
#initialize(type, value = nil) ⇒ Matcher
Returns a new instance of Matcher.
8 9 10 11 |
# File 'lib/mulang/inspection/matcher.rb', line 8 def initialize(type, value=nil) @type = type @value = value end |
Instance Attribute Details
#type ⇒ Object
Returns the value of attribute type.
6 7 8 |
# File 'lib/mulang/inspection/matcher.rb', line 6 def type @type end |
#value ⇒ Object
Returns the value of attribute value.
6 7 8 |
# File 'lib/mulang/inspection/matcher.rb', line 6 def value @value end |
Class Method Details
.parse(type, value) ⇒ Object
17 18 19 20 21 |
# File 'lib/mulang/inspection/matcher.rb', line 17 def self.parse(type, value) return nil unless type raise "Invalid matcher #{type}" unless type.in? TYPES new type.underscore.to_sym, value end |
Instance Method Details
#to_s ⇒ Object
13 14 15 |
# File 'lib/mulang/inspection/matcher.rb', line 13 def to_s "#{type.to_s.camelcase}#{value ? ":#{value}" : nil}" end |