Class: PrefixMachine
- Inherits:
-
Object
- Object
- PrefixMachine
- Defined in:
- lib/prefix-machine.rb,
lib/prefix-machine/version.rb,
ext/prefix_machine/prefix_machine.c
Constant Summary collapse
- VERSION =
'0.0.1'
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
Instance Method Summary collapse
- #guard!(str) ⇒ Object
- #initialize ⇒ Object constructor
- #insert(rule) ⇒ Object (also: #<<)
- #match(str) ⇒ Object
Constructor Details
#initialize ⇒ Object
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
5 6 7 |
# File 'lib/prefix-machine.rb', line 5 def count @count end |
Instance Method Details
#guard!(str) ⇒ Object
7 8 9 |
# File 'lib/prefix-machine.rb', line 7 def guard!(str) raise NoMatchingPatternError.new('No Such Patterns') unless str =~ /[0-9a-z.]*/ end |
#insert(rule) ⇒ Object Also known as: <<
11 12 13 14 15 |
# File 'lib/prefix-machine.rb', line 11 def insert(rule) s = rule.downcase guard!(s) trie_insert(s) end |
#match(str) ⇒ Object
17 18 19 20 21 |
# File 'lib/prefix-machine.rb', line 17 def match(str) s = str.downcase guard!(s) trie_match(s) end |