Class: AocCli::Commands::StatsTable

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ StatsTable



168
169
170
171
172
173
# File 'lib/aoc_cli/commands.rb', line 168

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.



167
168
169
# File 'lib/aoc_cli/commands.rb', line 167

def day
  @day
end

#userObject (readonly)

Returns the value of attribute user.



167
168
169
# File 'lib/aoc_cli/commands.rb', line 167

def user
  @user
end

#yearObject (readonly)

Returns the value of attribute year.



167
168
169
# File 'lib/aoc_cli/commands.rb', line 167

def year
  @year
end

Instance Method Details

#defaultsObject



179
180
181
182
183
# File 'lib/aoc_cli/commands.rb', line 179

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

#execObject



174
175
176
177
178
# File 'lib/aoc_cli/commands.rb', line 174

def exec
  day.nil? ?
    Tables::Stats::Year.new(u:user, y:year).print :
    Tables::Stats::Day.new(u:user, y:year, d:day).print
end