Sha256: 88b023ec0f8511797be1e131c1a2f05c8eafcd272f14ccc2170028c9ebb167d4

Contents?: true

Size: 927 Bytes

Versions: 7

Compression:

Stored size: 927 Bytes

Contents

module LearnWeb
  class Client
    module Lesson
      class CurrentLesson
        attr_reader   :response
        attr_accessor :data, :id, :title, :link, :github_repo, :forked_repo,
                      :assessments, :lab

        include LearnWeb::AttributePopulatable

        def initialize(response)
          @response = response

          parse!
        end

        def parse!
          case response.status
          when 200
            self.data = Oj.load(response.body, symbol_keys: true)
            populate_attributes!
          when 401
            puts "It seems your OAuth token is incorrect. Please re-run config with: learn reset"
            exit
          when 500
            puts "Something went wrong. Please try again."
            exit
          else
            puts "Something when wrong. Please try again."
            exit
          end

          self
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
learn-web-1.1.0 lib/learn_web/client/lesson/current_lesson.rb
learn-web-1.0.5 lib/learn_web/client/lesson/current_lesson.rb
learn-web-1.0.4 lib/learn_web/client/lesson/current_lesson.rb
learn-web-1.0.3 lib/learn_web/client/lesson/current_lesson.rb
learn-web-1.0.2 lib/learn_web/client/lesson/current_lesson.rb
learn-web-1.0.1 lib/learn_web/client/lesson/current_lesson.rb
learn-web-1.0.0 lib/learn_web/client/lesson/current_lesson.rb