Class: CommitLive::Current

Inherits:
Object
  • Object
show all
Defined in:
lib/commit-live/lesson/current.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#lessonObject

Returns the value of attribute lesson.



6
7
8
# File 'lib/commit-live/lesson/current.rb', line 6

def lesson
  @lesson
end

Instance Method Details

#getAttr(attr) ⇒ Object



28
29
30
31
32
# File 'lib/commit-live/lesson/current.rb', line 28

def getAttr(attr)
  if !attr.nil?
    lesson.fetch(attr)
  end
end

#getCurrentLesson(*puzzle_name) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/commit-live/lesson/current.rb', line 8

def getCurrentLesson(*puzzle_name)
  begin
    Timeout::timeout(15) do
      response = CommitLive::API.new().get('/bins/k8lsj')
      if response.status == 200
        @lesson = JSON.parse(response.body)
        # @lessonRepo = lesson.fetch('github_repo')
        # @lessonName = lesson.fetch('lesson_name')
      else
              puts "Something went wrong. Please try again."
                exit 1
      end
    end
  rescue Timeout::Error
    puts "Error while getting current lesson."
    puts "Please check your internet connection."
    exit
  end
end