Class: CodeLexer::Abstractor
- Inherits:
-
Object
- Object
- CodeLexer::Abstractor
- Defined in:
- lib/code-lexer/abstractor.rb
Instance Method Summary collapse
- #abstract!(tokens) ⇒ Object
- #abstract_comments ⇒ Object
- #abstract_everything ⇒ Object
- #abstract_identifiers ⇒ Object
- #abstract_numbers ⇒ Object
- #abstract_spaces ⇒ Object
- #abstract_strings ⇒ Object
- #deabstract!(tokens) ⇒ Object
- #dictionaries ⇒ Object
- #dictionary ⇒ Object
- #identifiers_dictionary ⇒ Object
-
#initialize(identifiers_dictionary = [], strings_dictionary = [], numbers_dictionary = []) ⇒ Abstractor
constructor
A new instance of Abstractor.
- #numbers_dictionary ⇒ Object
- #remove_comments ⇒ Object
- #remove_newlines ⇒ Object
- #remove_spaces ⇒ Object
- #strings_dictionary ⇒ Object
Constructor Details
#initialize(identifiers_dictionary = [], strings_dictionary = [], numbers_dictionary = []) ⇒ Abstractor
Returns a new instance of Abstractor.
5 6 7 8 9 10 11 12 |
# File 'lib/code-lexer/abstractor.rb', line 5 def initialize(identifiers_dictionary = [], strings_dictionary = [], numbers_dictionary = []) @dictionary = {} @dictionary[:identifiers] = ['NOOP'] + identifiers_dictionary @dictionary[:strings] = strings_dictionary @dictionary[:numbers] = numbers_dictionary @abstractor_pieces = [] end |
Instance Method Details
#abstract!(tokens) ⇒ Object
85 86 87 88 89 90 91 |
# File 'lib/code-lexer/abstractor.rb', line 85 def abstract!(tokens) @abstractor_pieces.each do |abstractor_piece| tokens = abstractor_piece.abstract(tokens) end return self end |
#abstract_comments ⇒ Object
55 56 57 58 |
# File 'lib/code-lexer/abstractor.rb', line 55 def abstract_comments @abstractor_pieces << CommentAbstractor.new(self) return self end |
#abstract_everything ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/code-lexer/abstractor.rb', line 14 def abstract_everything self.abstract_identifiers self.abstract_numbers self.abstract_comments self.abstract_strings self.abstract_spaces return self end |
#abstract_identifiers ⇒ Object
45 46 47 48 |
# File 'lib/code-lexer/abstractor.rb', line 45 def abstract_identifiers @abstractor_pieces << IdentifierAbstractor.new(self) return self end |
#abstract_numbers ⇒ Object
50 51 52 53 |
# File 'lib/code-lexer/abstractor.rb', line 50 def abstract_numbers @abstractor_pieces << NumberAbstractor.new(self) return self end |
#abstract_spaces ⇒ Object
65 66 67 68 |
# File 'lib/code-lexer/abstractor.rb', line 65 def abstract_spaces @abstractor_pieces << SpaceAbstractor.new(self) return self end |
#abstract_strings ⇒ Object
60 61 62 63 |
# File 'lib/code-lexer/abstractor.rb', line 60 def abstract_strings @abstractor_pieces << StringAbstractor.new(self) return self end |
#deabstract!(tokens) ⇒ Object
93 94 95 96 97 98 99 |
# File 'lib/code-lexer/abstractor.rb', line 93 def deabstract!(tokens) @abstractor_pieces.each do |abstractor_piece| tokens = abstractor_piece.deabstract(tokens) end return self end |
#dictionaries ⇒ Object
41 42 43 |
# File 'lib/code-lexer/abstractor.rb', line 41 def dictionaries @dictionary end |
#dictionary ⇒ Object
24 25 26 27 |
# File 'lib/code-lexer/abstractor.rb', line 24 def dictionary warn "[DEPRECATION] The method CodeLexer::Abstractor#dictionary is deprecated; used CodeLexer::Abstractor#identifiers_dictionary instead" self.identifiers_dictionary end |
#identifiers_dictionary ⇒ Object
29 30 31 |
# File 'lib/code-lexer/abstractor.rb', line 29 def identifiers_dictionary @dictionary[:identifiers] end |
#numbers_dictionary ⇒ Object
37 38 39 |
# File 'lib/code-lexer/abstractor.rb', line 37 def numbers_dictionary @dictionary[:numbers] end |
#remove_comments ⇒ Object
80 81 82 83 |
# File 'lib/code-lexer/abstractor.rb', line 80 def remove_comments @abstractor_pieces << CommentRemover.new(self) return self end |
#remove_newlines ⇒ Object
75 76 77 78 |
# File 'lib/code-lexer/abstractor.rb', line 75 def remove_newlines @abstractor_pieces << NewlineRemover.new(self) return self end |
#remove_spaces ⇒ Object
70 71 72 73 |
# File 'lib/code-lexer/abstractor.rb', line 70 def remove_spaces @abstractor_pieces << SpaceRemover.new(self) return self end |
#strings_dictionary ⇒ Object
33 34 35 |
# File 'lib/code-lexer/abstractor.rb', line 33 def strings_dictionary @dictionary[:strings] end |