Class: Stockade::Lexer
- Inherits:
-
Object
- Object
- Stockade::Lexer
- Extended by:
- Memoist
- Defined in:
- lib/stockade/lexer.rb
Overview
Class Lexer
Usage ‘Stockade::Lexer.call(context)`
Returns list of found lexemes.
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(context) ⇒ Lexer
constructor
A new instance of Lexer.
- #lexeme_classes ⇒ Object
Constructor Details
#initialize(context) ⇒ Lexer
Returns a new instance of Lexer.
20 21 22 |
# File 'lib/stockade/lexer.rb', line 20 def initialize(context) @context = context.dup end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
18 19 20 |
# File 'lib/stockade/lexer.rb', line 18 def context @context end |
Class Method Details
.call(context) ⇒ Object
24 25 26 |
# File 'lib/stockade/lexer.rb', line 24 def self.call(context) new(context).call end |
Instance Method Details
#call ⇒ Object
40 41 42 43 44 |
# File 'lib/stockade/lexer.rb', line 40 def call lexeme_classes.map do |lexeme_class| tokenize(lexeme_class) end.flatten end |
#lexeme_classes ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/stockade/lexer.rb', line 28 def lexeme_classes [ Stockade::Lexemes::PaymentCard, Stockade::Lexemes::Date, Stockade::Lexemes::Email, Stockade::Lexemes::Phone, Stockade::Lexemes::Word, Stockade::Lexemes::Firstname, Stockade::Lexemes::Lastname ] end |