// Copyright (c) 2024-2026 Celestino Amoroso (celestino.amoroso@gmail.com). // All rights reserved. // interval.go package interval import ( "fmt" "git.portale-stac.it/go-pkg/expr/kern" ) const TypeName = "interval" type IntervalType struct { begin, end, step int64 } func NewInterval(begin, end, step int64) *IntervalType { return &IntervalType{ begin: begin, end: end, step: step, } } func (p *IntervalType) Begin() int64 { return p.begin } func (p *IntervalType) End() int64 { return p.end } func (p *IntervalType) Step() int64 { return p.step } func IsInterval(v any) (ok bool) { _, ok = v.(*IntervalType) return ok } func (p *IntervalType) TypeName() string { return TypeName } func (p *IntervalType) ToString(opt kern.FmtOpt) string { return fmt.Sprintf("%d..%d..%d", p.begin, p.end, p.step) } func (p *IntervalType) String() string { return p.ToString(0) } func (p *IntervalType) ToIntTriple() (b, e, s int) { b = int(p.begin) e = int(p.end) s = int(p.step) return } // func (b *bool) EqualTo(other kern.Equaler) (equal bool) { // if otherBool, ok := other.(*bool); ok { // equal = b == otherBool // } // return // }