Class: AocCli::Commands::OpenReddit

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ OpenReddit



86
87
88
89
90
91
# File 'lib/aoc_cli/commands.rb', line 86

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

Instance Attribute Details

#browserObject (readonly)

Returns the value of attribute browser.



85
86
87
# File 'lib/aoc_cli/commands.rb', line 85

def browser
  @browser
end

#dayObject (readonly)

Returns the value of attribute day.



85
86
87
# File 'lib/aoc_cli/commands.rb', line 85

def day
  @day
end

#yearObject (readonly)

Returns the value of attribute year.



85
86
87
# File 'lib/aoc_cli/commands.rb', line 85

def year
  @year
end

Instance Method Details

#defaultsObject



96
97
98
99
100
# File 'lib/aoc_cli/commands.rb', line 96

def defaults
  { year:Metafile.get(:year),
    day:Metafile.get(:day),
    browser:Prefs.bool(key:"reddit_in_browser") }
end

#execObject



92
93
94
95
# File 'lib/aoc_cli/commands.rb', line 92

def exec
  Tools::Reddit.new(y:year, d:day, b:browser).open
  self
end