vars.*File.WithRelPath   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 6
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nop 1
dl 0
loc 6
rs 10
c 0
b 0
f 0
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