Class: HintableLevenshtein::Event
- Inherits:
-
Object
- Object
- HintableLevenshtein::Event
- Defined in:
- lib/hintable_levenshtein/event.rb
Instance Attribute Summary collapse
-
#chr ⇒ Object
readonly
Returns the value of attribute chr.
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(type, chr = nil) ⇒ Event
constructor
A new instance of Event.
- #to_s ⇒ Object
Constructor Details
#initialize(type, chr = nil) ⇒ Event
Returns a new instance of Event.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/hintable_levenshtein/event.rb', line 6 def initialize(type, chr = nil) @type = type case type when :substitute unless chr.nil? @from = chr.keys.first @from = @from.chr unless @from.is_a?(String) @to = chr.values.first @to = @to.chr unless @to.is_a?(String) else @from = @to = nil end else @chr = chr.is_a?(String) ? chr : chr.chr end end |
Instance Attribute Details
#chr ⇒ Object (readonly)
Returns the value of attribute chr.
4 5 6 |
# File 'lib/hintable_levenshtein/event.rb', line 4 def chr @chr end |
#from ⇒ Object (readonly)
Returns the value of attribute from.
4 5 6 |
# File 'lib/hintable_levenshtein/event.rb', line 4 def from @from end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
4 5 6 |
# File 'lib/hintable_levenshtein/event.rb', line 4 def to @to end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
4 5 6 |
# File 'lib/hintable_levenshtein/event.rb', line 4 def type @type end |
Instance Method Details
#to_s ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/hintable_levenshtein/event.rb', line 23 def to_s if from "#{type} -> #{from}..#{to}" else "#{type} -> #{chr}" end end |