aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-05-15 13:29:31 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-05-15 13:29:31 +0200
commitb2bfa9c8f48fced0776986c68135a75f9c3f3a46 (patch)
treeb524128059644fcd0a9f874a0fd22091018aef5c
parent45480ea2d167ec9107b837bf14102531521366ab (diff)
Rename New... to parse...
-rw-r--r--cutter.go6
-rw-r--r--robo.go6
-rw-r--r--units.go8
3 files changed, 10 insertions, 10 deletions
diff --git a/cutter.go b/cutter.go
index d77a5a2..0cfcff3 100644
--- a/cutter.go
+++ b/cutter.go
@@ -270,15 +270,15 @@ func (c Cutter) returnString() string {
}
func (c Cutter) returnUnit() Unit {
- return NewUnit(c.Response())
+ return parseUnit(c.Response())
}
func (c Cutter) returnPoint() Point {
- return NewPoint(c.Response())
+ return parsePoint(c.Response())
}
func (c Cutter) returnTriple() Triple {
- return NewTriple(c.Response())
+ return parseTriple(c.Response())
}
func (c Cutter) RegMarkLen(n Unit) {
diff --git a/robo.go b/robo.go
index 3811500..b7a39c6 100644
--- a/robo.go
+++ b/robo.go
@@ -87,7 +87,7 @@ func Init(c *bufio.Writer) { esc(c, 4) }
func Ready(c *bufio.ReadWriter) bool {
esc(c.Writer, 5)
- return NewUnit(recv(c.Reader)) == 0
+ return parseUnit(recv(c.Reader)) == 0
}
func recv(c *bufio.Reader) string {
@@ -115,7 +115,7 @@ func Calibrate(c *bufio.Writer) { send(c, "TB70") }
func point(c *bufio.ReadWriter, cmd string) Point {
send(c.Writer, cmd)
- return NewPoint(recv(c.Reader))
+ return parsePoint(recv(c.Reader))
}
func Calibration(c *bufio.ReadWriter) Point { return point(c, "TB71") }
@@ -131,7 +131,7 @@ func (p Point) LineStyle(c *bufio.Writer) { p.send(c, "L100,1,") }
func triple(c *bufio.ReadWriter, cmd string) Triple {
send(c.Writer, cmd)
- return NewTriple(recv(c.Reader))
+ return parseTriple(recv(c.Reader))
}
func Gin(c *bufio.ReadWriter) Triple { return triple(c, "G") }
diff --git a/units.go b/units.go
index 686d5f2..7e3d12e 100644
--- a/units.go
+++ b/units.go
@@ -15,13 +15,13 @@ type Unit float64
func (u Unit) String() string {
if u == Unit(int(u)) {
- return fmt.Sprintf("%d", int(u))
+ return fmt.Sprint(int(u))
} else {
return fmt.Sprintf("%.2f", u)
}
}
-func NewUnit(s string) (u Unit) {
+func parseUnit(s string) (u Unit) {
fmt.Sscanf(s, "%v", &u)
return
}
@@ -34,7 +34,7 @@ func (p Point) String() string {
return fmt.Sprintf("%v,%v", p.X, p.Y)
}
-func NewPoint(s string) (p Point) {
+func parsePoint(s string) (p Point) {
fmt.Sscanf(s, "%v,%v", &p.X, &p.Y)
return
}
@@ -47,7 +47,7 @@ func (t Triple) String() string {
return fmt.Sprintf("%v,%v,%v", t.U, t.V, t.W)
}
-func NewTriple(s string) (t Triple) {
+func parseTriple(s string) (t Triple) {
fmt.Sscanf(s, "%v,%v,%v", &t.U, &t.V, &t.W)
return
}