shifter

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 13, 2022 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package shifter provide simple routing by dividing path into its segment

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Shifter

type Shifter struct {
	// contains filtered or unexported fields
}

Shifter hold state of shifting segment in the path

func New

func New(list []string) *Shifter

New return new Shifter with the key

func (*Shifter) ClearTag

func (s *Shifter) ClearTag(index int)

ClearTag clear all tags on index

func (*Shifter) CurrentIndex

func (s *Shifter) CurrentIndex() int

CurrentIndex of shifter state

func (*Shifter) DeleteTag

func (s *Shifter) DeleteTag(tag string)

DeleteTag delete tag

func (*Shifter) End

func (s *Shifter) End() bool

End indicated end segment in the path

func (*Shifter) Get

func (s *Shifter) Get(i int) string

Get i-th segment

func (*Shifter) GetByTag

func (s *Shifter) GetByTag(tag string) (string, bool)

GetByTag return tagged segment

func (*Shifter) GetRelative

func (s *Shifter) GetRelative(d int) string

GetRelative is same with Get, but relative to current segment

func (*Shifter) Reset

func (s *Shifter) Reset()

Reset the shifter

func (*Shifter) SetNext

func (s *Shifter) SetNext(next int)

SetNext set the index for the next Shift.

func (*Shifter) Shift

func (s *Shifter) Shift() (string, bool)

Shift to next segment, also telling if already in last segment

func (*Shifter) Size

func (s *Shifter) Size() int

Size return the size of segment in path

func (*Shifter) Split

func (s *Shifter) Split() (done []string, rest []string)

Split return processed segment and rest of them

func (*Shifter) Tag

func (s *Shifter) Tag(tag string)

Tag current segment

func (*Shifter) TagIndex

func (s *Shifter) TagIndex(i int, tag string)

TagIndex will tag i-th segment

func (*Shifter) TagRelative

func (s *Shifter) TagRelative(d int, tag string)

TagRelative is same with TagIndex, but relative to current segment

func (*Shifter) Unshift

func (s *Shifter) Unshift()

Unshift do reverse of Shift

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL