Class: Zenlish::Inflect::MatchesPattern
- Inherits:
-
UnaryInputExpression
- Object
- InputExpression
- UnaryInputExpression
- Zenlish::Inflect::MatchesPattern
- Defined in:
- lib/zenlish/inflect/matches_pattern.rb
Instance Attribute Summary collapse
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
Attributes inherited from UnaryInputExpression
Instance Method Summary collapse
-
#initialize(anArgument, aPattern) ⇒ MatchesPattern
constructor
A new instance of MatchesPattern.
- #success?(headings, lexeme, actuals) ⇒ Boolean
Constructor Details
#initialize(anArgument, aPattern) ⇒ MatchesPattern
Returns a new instance of MatchesPattern.
8 9 10 11 |
# File 'lib/zenlish/inflect/matches_pattern.rb', line 8 def initialize(anArgument, aPattern) super(anArgument) @pattern = aPattern end |
Instance Attribute Details
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
6 7 8 |
# File 'lib/zenlish/inflect/matches_pattern.rb', line 6 def pattern @pattern end |
Instance Method Details
#success?(headings, lexeme, actuals) ⇒ Boolean
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/zenlish/inflect/matches_pattern.rb', line 13 def success?(headings, lexeme, actuals) val = nil if actuals.empty? # require 'debug' hd = headings[argument.index] val = hd.evaluate_for(lexeme) else val = actuals[argument.index] end val =~ pattern end |