variable

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InMemoryStorer

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

InMemoryStorer stores variables from a dialogue using in-memory maps.

func NewInMemoryStorer

func NewInMemoryStorer() *InMemoryStorer

NewInMemoryStorer creates a new empty InMemoryStorer.

func (*InMemoryStorer) Clear

func (storer *InMemoryStorer) Clear()

Clear removes all variables from the store.

func (*InMemoryStorer) Contains

func (storer *InMemoryStorer) Contains(variableName string) bool

Contains returns whether a variable with the given name is currently stored.

func (*InMemoryStorer) GetValue

func (storer *InMemoryStorer) GetValue(variableName string) (*Value, bool)

GetValue returns the value of a variable, if it is stored.

func (*InMemoryStorer) GetValues added in v0.0.7

func (storer *InMemoryStorer) GetValues() map[string]Value

GetValues returns a map of all stored values.

func (*InMemoryStorer) SetBooleanValue

func (storer *InMemoryStorer) SetBooleanValue(variableName string, value bool)

SetBooleanValue stores a boolean.

func (*InMemoryStorer) SetNumberValue

func (storer *InMemoryStorer) SetNumberValue(variableName string, value float64)

SetNumberValue stores a number.

func (*InMemoryStorer) SetStringValue

func (storer *InMemoryStorer) SetStringValue(variableName string, value string)

SetStringValue stores a string.

type Retriever

type Retriever interface {
	GetValue(variableName string) (*Value, bool)

	GetValues() map[string]Value

	Contains(variableName string) bool
}

Retriever allows to access stored variable values.

type Storer

type Storer interface {
	Retriever

	SetNumberValue(variableName string, value float64)
	SetBooleanValue(variableName string, value bool)
	SetStringValue(variableName string, value string)

	Clear()
}

Storer allows to access and modify stored variable values.

type Value

type Value struct {
	Number  *float64
	Boolean *bool
	String  *string
}

Value holds an evaluated value of a YarnSpinner script.

func NewBoolean

func NewBoolean(boolean bool) *Value

NewBoolean creates a new YarnSpinner dialogue value from the given boolean.

func NewNumber

func NewNumber(number float64) *Value

NewNumber creates a new YarnSpinner dialogue value from the given number.

func NewString

func NewString(str string) *Value

NewString creates a new YarnSpinner dialogue value from the given string.

func (*Value) ToString

func (v *Value) ToString() string

ToString serializes a value into a string.

Jump to

Keyboard shortcuts

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