Class: Regexp::Token

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nextObject

Returns the value of attribute next.



15
16
17
# File 'lib/regexp_parser/token.rb', line 15

def next
  @next
end

#previousObject

Returns the value of attribute previous.



15
16
17
# File 'lib/regexp_parser/token.rb', line 15

def previous
  @previous
end

Instance Method Details

#lengthObject



21
22
23
# File 'lib/regexp_parser/token.rb', line 21

def length
  te - ts
end

#offsetObject



17
18
19
# File 'lib/regexp_parser/token.rb', line 17

def offset
  [ts, te]
end

#to_hObject



26
27
28
29
30
31
# File 'lib/regexp_parser/token.rb', line 26

def to_h
  members.inject({}) do |hash, member|
    hash[member.to_sym] = self[member]
    hash
  end
end