Class: JLDrill::Deinflection::Match
- Inherits:
-
Array
- Object
- Array
- JLDrill::Deinflection::Match
- Defined in:
- lib/jldrill/model/DeinflectionRules.rb
Class Method Summary collapse
Instance Method Summary collapse
- #apply(rule) ⇒ Object
- #hasReason(rule) ⇒ Object
-
#initialize(transform, history = nil) ⇒ Match
constructor
A new instance of Match.
- #to_s ⇒ Object
- #transforms ⇒ Object
Constructor Details
#initialize(transform, history = nil) ⇒ Match
Returns a new instance of Match.
85 86 87 88 89 90 91 92 |
# File 'lib/jldrill/model/DeinflectionRules.rb', line 85 def initialize(transform, history=nil) if !history.nil? super(history) else super() end push(transform) end |
Class Method Details
Instance Method Details
#apply(rule) ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/jldrill/model/DeinflectionRules.rb', line 108 def apply(rule) retVal = nil if !last.nil? && !hasReason(rule) re = Regexp.new("(.*)#{rule.original}", nil) if re.match(last.dictionary) transform = Transform.new(last.dictionary, $1, rule) retVal = Match.new(transform, self) end end return retVal end |
#hasReason(rule) ⇒ Object
98 99 100 101 102 103 104 105 106 |
# File 'lib/jldrill/model/DeinflectionRules.rb', line 98 def hasReason(rule) any? do |transform| if !transform.nil? && !transform.rule.nil? transform.rule.reason.eql?(rule.reason) else false end end end |
#to_s ⇒ Object
130 131 132 |
# File 'lib/jldrill/model/DeinflectionRules.rb', line 130 def to_s transforms end |
#transforms ⇒ Object
120 121 122 123 124 125 126 127 128 |
# File 'lib/jldrill/model/DeinflectionRules.rb', line 120 def transforms collect do |transform| if !transform.rule.nil? "(#{transform.root}#{transform.rule.original}) #{transform.rule.reason}: #{transform.dictionary}" else transform.dictionary end end.join(" > ") end |