mirror of
https://github.com/danog/parser.git
synced 2024-11-27 04:14:55 +01:00
35 lines
410 B
Go
35 lines
410 B
Go
package value
|
|
|
|
import (
|
|
"fmt"
|
|
"strconv"
|
|
)
|
|
|
|
type Int struct {
|
|
value int
|
|
}
|
|
|
|
func NewInt(value int) *Int {
|
|
return &Int{value}
|
|
}
|
|
|
|
func (i *Int) ToString() string {
|
|
return strconv.Itoa(i.value)
|
|
}
|
|
|
|
func (i *Int) ToInt() int {
|
|
return i.value
|
|
}
|
|
|
|
func (i *Int) IsString() bool {
|
|
return false
|
|
}
|
|
|
|
func (i *Int) IsInt() bool {
|
|
return true
|
|
}
|
|
|
|
func (i *Int) Dump() string {
|
|
return fmt.Sprintf("int(%d)", i.value)
|
|
}
|