Class: Mulang::Inspection::Matcher
- Inherits:
-
Object
- Object
- Mulang::Inspection::Matcher
- Includes:
- Compacted
- Defined in:
- lib/mulang/inspection/matcher.rb
Constant Summary collapse
- TYPES =
%w( WithAnything WithChar WithFalse WithLiteral WithLogic WithMath WithNil WithNonliteral WithNumber WithReference WithString WithSymbol WithTrue WithAnyString WithAnyNumber)
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.
13 14 15 16 |
# File 'lib/mulang/inspection/matcher.rb', line 13 def initialize(type, value=nil) @type = type @value = value end |
Instance Attribute Details
#type ⇒ Object
Returns the value of attribute type.
11 12 13 |
# File 'lib/mulang/inspection/matcher.rb', line 11 def type @type end |
#value ⇒ Object
Returns the value of attribute value.
11 12 13 |
# File 'lib/mulang/inspection/matcher.rb', line 11 def value @value end |
Class Method Details
.parse(type, value) ⇒ Object
22 23 24 25 26 |
# File 'lib/mulang/inspection/matcher.rb', line 22 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
18 19 20 |
# File 'lib/mulang/inspection/matcher.rb', line 18 def to_s "#{type.to_s.camelcase}#{value ? ":#{value}" : nil}" end |