Class: AocCli::Paths::Year

Inherits:
Object
  • Object
show all
Defined in:
lib/aoc_cli/paths.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(u: Metafile.get(:user), y: Metafile.get(:year)) ⇒ Year

Returns a new instance of Year.



6
7
8
9
10
# File 'lib/aoc_cli/paths.rb', line 6

def initialize(u:Metafile.get(:user),
			   y:Metafile.get(:year))
	@user = Validate.user(u)
	@year = Validate.year(y)
end

Instance Attribute Details

#userObject (readonly)

Returns the value of attribute user.



5
6
7
# File 'lib/aoc_cli/paths.rb', line 5

def user
  @user
end

#yearObject (readonly)

Returns the value of attribute year.



5
6
7
# File 'lib/aoc_cli/paths.rb', line 5

def year
  @year
end

Instance Method Details

#filename(f:) ⇒ Object



22
23
24
25
26
27
# File 'lib/aoc_cli/paths.rb', line 22

def filename(f:)
	case f.to_sym
	when :Stars then "#{year}.md"
	when :meta  then ".meta"
	end
end

#in_year?Boolean

Returns:

  • (Boolean)


11
12
13
14
# File 'lib/aoc_cli/paths.rb', line 11

def in_year?
	File.exist?("./.meta") ? 
		Metafile.type == :ROOT : true
end

#local(f:) ⇒ Object



18
19
20
21
# File 'lib/aoc_cli/paths.rb', line 18

def local(f:)
	"#{Validate.not_init(dir:year_dir, 
		year:year)}/#{filename(f:f)}"
end

#year_dirObject



15
16
17
# File 'lib/aoc_cli/paths.rb', line 15

def year_dir
	in_year? ? "." : ".."
end