Class: Regexp::Token
- Inherits:
-
Struct
- Object
- Struct
- Regexp::Token
- Defined in:
- lib/regexp_parser/token.rb
Instance Method Summary collapse
- #length ⇒ Object
- #next(exp = nil) ⇒ Object
- #offset ⇒ Object
- #previous(exp = nil) ⇒ Object
- #to_h ⇒ Object
Instance Method Details
#length ⇒ Object
9 10 11 |
# File 'lib/regexp_parser/token.rb', line 9 def length self.te - self.ts end |
#next(exp = nil) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/regexp_parser/token.rb', line 20 def next(exp = nil) if exp @next = exp else @next end end |
#offset ⇒ Object
5 6 7 |
# File 'lib/regexp_parser/token.rb', line 5 def offset [self.ts, self.te] end |
#previous(exp = nil) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/regexp_parser/token.rb', line 28 def previous(exp = nil) if exp @previous = exp else @previous end end |
#to_h ⇒ Object
13 14 15 16 17 18 |
# File 'lib/regexp_parser/token.rb', line 13 def to_h hash = {} members.each do |member| hash[member.to_sym] = self.send(member.to_sym) end; hash end |