vars/file.go   A
last analyzed

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 24
dl 0
loc 39
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A vars.*File.Tags 0 2 1
A vars.*File.RelPath 0 2 1
A vars.NewFile 0 4 1
A vars.*File.Filename 0 2 1
A vars.*File.WithRelPath 0 6 2
1
package vars
2
3
import (
4
	"github.com/vvval/go-metadata-scanner/vars/metadata"
5
	"path/filepath"
6
)
7
8
type File struct {
9
	filename string //parsed with filepath.ToSlashes
10
	relPath  string
11
	tags     metadata.Tags
12
}
13
14
func NewFile(filename string, tags metadata.Tags) File {
15
	return File{
16
		filename: filename,
17
		tags:     tags,
18
	}
19
}
20
21
func (f *File) Filename() string {
22
	return f.filename
23
}
24
25
func (f *File) WithRelPath(base string) {
26
	rel, err := filepath.Rel(base, f.filename)
27
	if err != nil {
28
		f.relPath = f.filename
29
	} else {
30
		f.relPath = rel
31
	}
32
}
33
34
func (f *File) RelPath() string {
35
	return f.relPath
36
}
37
38
func (f *File) Tags() metadata.Tags {
39
	return f.tags
40
}
41