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
19 20 21 |
# File 'lib/regexp_parser/token.rb', line 19 def length self.te - self.ts end |
#next(exp = nil) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/regexp_parser/token.rb', line 23 def next(exp = nil) if exp @next = exp else @next end end |
#offset ⇒ Object
15 16 17 |
# File 'lib/regexp_parser/token.rb', line 15 def offset [self.ts, self.te] end |
#previous(exp = nil) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/regexp_parser/token.rb', line 31 def previous(exp = nil) if exp @previous = exp else @previous end end |
#to_h ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/regexp_parser/token.rb', line 40 def to_h hash = {} members.each do |member| hash[member.to_sym] = self.send(member.to_sym) end hash end |