Class: AocCli::Commands::DayInit

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ DayInit

Returns a new instance of DayInit.



42
43
44
45
46
47
# File 'lib/aoc_cli/commands.rb', line 42

def initialize(args)
	args  = defaults.merge(args).compact
	@user = args[:user]
	@year = args[:year]
	@day  = args[:day]
end

Instance Attribute Details

#dayObject (readonly)

Returns the value of attribute day.



41
42
43
# File 'lib/aoc_cli/commands.rb', line 41

def day
  @day
end

#userObject (readonly)

Returns the value of attribute user.



41
42
43
# File 'lib/aoc_cli/commands.rb', line 41

def user
  @user
end

#yearObject (readonly)

Returns the value of attribute year.



41
42
43
# File 'lib/aoc_cli/commands.rb', line 41

def year
  @year
end

Instance Method Details

#defaultsObject



53
54
55
56
# File 'lib/aoc_cli/commands.rb', line 53

def defaults
	{ user:Metafile.get(:user), 
	  year:Metafile.get(:year) }
end

#execObject



48
49
50
51
52
# File 'lib/aoc_cli/commands.rb', line 48

def exec
	Day::Init.new(u:user, y:year, d:day).mkdir.meta
	Day::Pages.new(u:user, y:year, d:day).load
	self
end

#respondObject



57
58
59
# File 'lib/aoc_cli/commands.rb', line 57

def respond
	puts "Day #{day} initialised"
end