Class: Regexp::Token
- Inherits:
-
Struct
- Object
- Struct
- Regexp::Token
- Defined in:
- lib/regexp_parser/token.rb
Instance Method Summary collapse
-
#initialize ⇒ Token
constructor
A new instance of Token.
- #length ⇒ Object
- #next(exp = nil) ⇒ Object
- #offset ⇒ Object
- #previous(exp = nil) ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize ⇒ Token
Returns a new instance of Token.
15 16 17 18 19 |
# File 'lib/regexp_parser/token.rb', line 15 def initialize(*) super @previous = @next = nil end |
Instance Method Details
#length ⇒ Object
25 26 27 |
# File 'lib/regexp_parser/token.rb', line 25 def length self.te - self.ts end |
#next(exp = nil) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/regexp_parser/token.rb', line 29 def next(exp = nil) if exp @next = exp else @next end end |
#offset ⇒ Object
21 22 23 |
# File 'lib/regexp_parser/token.rb', line 21 def offset [self.ts, self.te] end |
#previous(exp = nil) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/regexp_parser/token.rb', line 37 def previous(exp = nil) if exp @previous = exp else @previous end end |
#to_h ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/regexp_parser/token.rb', line 46 def to_h hash = {} members.each do |member| hash[member.to_sym] = self.send(member.to_sym) end hash end |