Class: Arb::Api::OtherSolutions

Inherits:
Object
  • Object
show all
Defined in:
lib/arb/api/other_solutions.rb

Instance Method Summary collapse

Constructor Details

#initialize(year:, day:, part:) ⇒ OtherSolutions

Returns a new instance of OtherSolutions.



6
7
8
9
10
11
# File 'lib/arb/api/other_solutions.rb', line 6

def initialize(year:, day:, part:)
  @year = year
  @day = day
  @part = part
  @gem_directory = Gem.loaded_specs["advent_of_ruby"].gem_dir
end

Instance Method Details

#other_solutionsObject



13
14
15
16
17
18
19
20
21
# File 'lib/arb/api/other_solutions.rb', line 13

def other_solutions
  unless File.exist?(reddit_file_path)
    return no_solutions_for_year_message
  end

  "#{year} Day #{day.to_i} Part #{part}\n\n" \
    "#{github_solutions}" \
    "#{reddit_solutions if part.to_i == 2}".rstrip + "\n"
end