restructure project
Some checks failed
Build / build (push) Failing after 5m21s
Publish Image / publish (push) Failing after 32s
Test / build (push) Failing after 5m8s

This commit is contained in:
Chuck Smith
2024-03-28 16:20:09 -04:00
parent 362138ff2e
commit fc6ceee02c
93 changed files with 479 additions and 194 deletions

48
internal/object/str.go Normal file
View File

@@ -0,0 +1,48 @@
package object
import (
"fmt"
"unicode/utf8"
)
type String struct {
Value string
}
func (s *String) Len() int {
return utf8.RuneCountInString(s.Value)
}
func (s *String) Bool() bool {
return s.Value != ""
}
func (s *String) Type() ObjectType {
return STRING_OBJ
}
func (s *String) Inspect() string {
return fmt.Sprintf("%#v", s.Value)
}
func (s *String) Clone() Object {
return &String{Value: s.Value}
}
func (s *String) String() string {
return s.Value
}
func (s *String) Compare(other Object) int {
if obj, ok := other.(*String); ok {
switch {
case s.Value < obj.Value:
return -1
case s.Value > obj.Value:
return 1
default:
return 0
}
}
return 1
}