class ProjectEulerCli::ArchiveViewer
Handles the work of displaying information about the problems.
Public Class Methods
new()
click to toggle source
# File lib/project_euler_cli/archive_viewer.rb, line 7 def initialize lookup_totals end
Public Instance Methods
display_custom_page(list)
click to toggle source
Displays a custom page of problems given by an array of IDs.
-
list
- Array of problem IDs
# File lib/project_euler_cli/archive_viewer.rb, line 59 def display_custom_page(list) puts list.each { |id| puts "#{id} - #{Problem[id].title}" } end
display_page(page)
click to toggle source
Displays the problem numbers and titles for an individual page of the archive.
# File lib/project_euler_cli/archive_viewer.rb, line 24 def display_page(page) load_page(page) puts start = (page - 1) * Page::LENGTH + 1 start.upto(start + Page::LENGTH - 1) do |i| puts "#{i} - #{Problem[i].title}" unless i >= Problem.total - 9 end end
display_problem(id)
click to toggle source
Displays the details of an individual problem.
-
id
- ID of the problem to be displayed
# File lib/project_euler_cli/archive_viewer.rb, line 38 def display_problem(id) load_problem_details(id) puts puts "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=" puts puts Problem[id].title.upcase puts "Problem #{id}" puts puts Problem[id].published puts Problem[id].solved_by puts Problem[id].difficulty if id < Problem.total - 9 puts puts "https://projecteuler.net/problem=#{id}" puts puts "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=" end
display_recent()
click to toggle source
Displays the 10 most recently added problems.
# File lib/project_euler_cli/archive_viewer.rb, line 12 def display_recent load_recent puts (Problem.total).downto(Problem.total - 9) do |i| puts "#{i} - #{Problem[i].title}" end end