Sha256: 61d6bd4b176e1c97f2db1dc9e3cb3ab231e7472fe94844a036f840e67765c121

Contents?: true

Size: 719 Bytes

Versions: 10

Compression:

Stored size: 719 Bytes

Contents

module Hexlet
  # FIXME add uri parser
  class Router
    def initialize(host = "http://hexlet.io")
      @host = host
    end

    def api_member_lesson_backend_results_url(lesson_slug, exercise_slug)
      generate("api_member/lessons/%s/backends/%s/results" % [lesson_slug, exercise_slug])
    end

    def api_member_lesson_backend_url(lesson_slug, exercise_slug)
      generate("api_member/lessons/%s/backends/%s" % [lesson_slug, exercise_slug])
    end

    def api_teacher_lessons_url
      generate("api_teacher/lessons")
    end

    def api_member_user_check_url
      generate("api_member/user/check_auth")
    end

    private

    def generate(url)
      URI("#{@host}/#{url}.json").to_s
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
hexlet-0.3.4 lib/hexlet/router.rb
hexlet-0.3.3 lib/hexlet/router.rb
hexlet-0.3.2 lib/hexlet/router.rb
hexlet-0.3.1 lib/hexlet/router.rb
hexlet-0.3.0 lib/hexlet/router.rb
hexlet-0.2.2 lib/hexlet/router.rb
hexlet-0.2.1 lib/hexlet/router.rb
hexlet-0.2.0 lib/hexlet/router.rb
hexlet-0.1.1 lib/hexlet/router.rb
hexlet-0.1.0 lib/hexlet/router.rb