Class: Regexp::Token

Inherits:
Struct
  • Object
show all
Defined in:
lib/regexp_parser/token.rb

Instance Method Summary collapse

Instance Method Details

#lengthObject



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

#offsetObject



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_hObject



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