File: device.go

package info (click to toggle)
golang-github-ua-parser-uap-go 0.0~git20200325.e1c09f1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 4,840 kB
  • sloc: makefile: 5; sh: 4
file content (30 lines) | stat: -rw-r--r-- 723 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package uaparser

import "strings"

type Device struct {
	Family string
	Brand  string
	Model  string
}

func (parser *deviceParser) Match(line string, dvc *Device) {
	matches := parser.Reg.FindStringSubmatchIndex(line)

	if len(matches) == 0 {
		return
	}

	dvc.Family = string(parser.Reg.ExpandString(nil, parser.DeviceReplacement, line, matches))
	dvc.Family = strings.TrimSpace(dvc.Family)

	dvc.Brand = string(parser.Reg.ExpandString(nil, parser.BrandReplacement, line, matches))
	dvc.Brand = strings.TrimSpace(dvc.Brand)

	dvc.Model = string(parser.Reg.ExpandString(nil, parser.ModelReplacement, line, matches))
	dvc.Model = strings.TrimSpace(dvc.Model)
}

func (dvc *Device) ToString() string {
	return dvc.Family
}