Class: AocCli::Commands::YearInit

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ YearInit

Returns a new instance of YearInit.



22
23
24
25
# File 'lib/aoc_cli/commands.rb', line 22

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

Instance Attribute Details

#gitObject (readonly)

Returns the value of attribute git.



21
22
23
# File 'lib/aoc_cli/commands.rb', line 21

def git
  @git
end

#userObject (readonly)

Returns the value of attribute user.



21
22
23
# File 'lib/aoc_cli/commands.rb', line 21

def user
  @user
end

#yearObject (readonly)

Returns the value of attribute year.



21
22
23
# File 'lib/aoc_cli/commands.rb', line 21

def year
  @year
end

Instance Method Details

#defaultsObject



35
36
37
38
# File 'lib/aoc_cli/commands.rb', line 35

def defaults
  { user:Prefs.default_alias,
     git:Prefs.bool(key:"init_git") }
end

#execObject



26
27
28
29
30
31
# File 'lib/aoc_cli/commands.rb', line 26

def exec
  Year::Meta.new(u:user, y:year).write
  Year::Progress.new(u:user, y:year).write.init_calendar_db
  Year::GitWrap.new if git
  self
end

#respondObject



32
33
34
# File 'lib/aoc_cli/commands.rb', line 32

def respond
  puts "Year #{year} initialised"
end