Class: YTools::Path::Token

Inherits:
Struct
  • Object
show all
Defined in:
lib/ytools/path/lexer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#lengthObject

Returns the value of attribute length

Returns:

  • (Object)

    the current value of length



5
6
7
# File 'lib/ytools/path/lexer.rb', line 5

def length
  @length
end

#offsetObject

Returns the value of attribute offset

Returns:

  • (Object)

    the current value of offset



5
6
7
# File 'lib/ytools/path/lexer.rb', line 5

def offset
  @offset
end

#pathObject

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



5
6
7
# File 'lib/ytools/path/lexer.rb', line 5

def path
  @path
end

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



5
6
7
# File 'lib/ytools/path/lexer.rb', line 5

def type
  @type
end

Instance Method Details

#valueObject



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/ytools/path/lexer.rb', line 6

def value
  case type
    when :path_separator then '/'
    when :path_part then path # We cheat and put in the actual
                              # value of the path part here, 
                              # because we don't care about the offset
    when :lbrace then '['
    when :rbrace then ']'
    when :number then path[offset, length].to_i
    else raise YPath::PathError("Unrecognized token type!!!!")
  end
end