Class: LearnOpen::Lessons::BaseLesson

Inherits:
Object
  • Object
show all
Defined in:
lib/learn_open/lessons/base_lesson.rb

Direct Known Subclasses

IosLesson, JupyterLesson, LabLesson, ReadmeLesson

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lesson_data, options = {}) ⇒ BaseLesson

Returns a new instance of BaseLesson.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/learn_open/lessons/base_lesson.rb', line 20

def initialize(lesson_data, options = {})
  lesson = lesson_data[:lesson]

  @repo_path = lesson.clone_repo
  @organization, @name = repo_path.split('/')

  @git_server = lesson.git_server
  @dot_learn = lesson.dot_learn
  @is_lab = lesson.lab
  @use_student_fork = lesson.use_student_fork
  @later_lesson = lesson_data[:later_lesson]
  @id = lesson_data[:id]

  @logger = options.fetch(:logger, LearnOpen.logger)
  @io = options.fetch(:io, LearnOpen.default_io)
  @system_adapter = options.fetch(:system_adapter, LearnOpen.system_adapter)
  @platform = options.fetch(:platform, LearnOpen.platform)
  @environment_vars = options.fetch(:environment_vars, LearnOpen.environment_vars)
  @location = options.fetch(:lessons_directory) {LearnOpen.lessons_directory}
  @options = options
end

Instance Attribute Details

#dot_learnObject (readonly)

Returns the value of attribute dot_learn.



4
5
6
# File 'lib/learn_open/lessons/base_lesson.rb', line 4

def dot_learn
  @dot_learn
end

#environment_varsObject (readonly)

Returns the value of attribute environment_vars.



4
5
6
# File 'lib/learn_open/lessons/base_lesson.rb', line 4

def environment_vars
  @environment_vars
end

#git_serverObject (readonly)

Returns the value of attribute git_server.



4
5
6
# File 'lib/learn_open/lessons/base_lesson.rb', line 4

def git_server
  @git_server
end

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/learn_open/lessons/base_lesson.rb', line 4

def id
  @id
end

#ioObject (readonly)

Returns the value of attribute io.



4
5
6
# File 'lib/learn_open/lessons/base_lesson.rb', line 4

def io
  @io
end

#later_lessonObject (readonly)

Returns the value of attribute later_lesson.



4
5
6
# File 'lib/learn_open/lessons/base_lesson.rb', line 4

def later_lesson
  @later_lesson
end

#locationObject (readonly)

Returns the value of attribute location.



4
5
6
# File 'lib/learn_open/lessons/base_lesson.rb', line 4

def location
  @location
end

#loggerObject (readonly)

Returns the value of attribute logger.



4
5
6
# File 'lib/learn_open/lessons/base_lesson.rb', line 4

def logger
  @logger
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/learn_open/lessons/base_lesson.rb', line 4

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/learn_open/lessons/base_lesson.rb', line 4

def options
  @options
end

#organizationObject (readonly)

Returns the value of attribute organization.



4
5
6
# File 'lib/learn_open/lessons/base_lesson.rb', line 4

def organization
  @organization
end

#platformObject (readonly)

Returns the value of attribute platform.



4
5
6
# File 'lib/learn_open/lessons/base_lesson.rb', line 4

def platform
  @platform
end

#repo_pathObject (readonly)

Returns the value of attribute repo_path.



4
5
6
# File 'lib/learn_open/lessons/base_lesson.rb', line 4

def repo_path
  @repo_path
end

#system_adapterObject (readonly)

Returns the value of attribute system_adapter.



4
5
6
# File 'lib/learn_open/lessons/base_lesson.rb', line 4

def system_adapter
  @system_adapter
end

#use_student_forkObject (readonly)

Returns the value of attribute use_student_fork.



4
5
6
# File 'lib/learn_open/lessons/base_lesson.rb', line 4

def use_student_fork
  @use_student_fork
end

Instance Method Details

#lab?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/learn_open/lessons/base_lesson.rb', line 42

def lab?
  @is_lab
end

#readme?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/learn_open/lessons/base_lesson.rb', line 46

def readme?
  !lab?
end

#to_pathObject



50
51
52
# File 'lib/learn_open/lessons/base_lesson.rb', line 50

def to_path
  "#{location}/#{name}"
end

#to_urlObject



54
55
56
# File 'lib/learn_open/lessons/base_lesson.rb', line 54

def to_url
  "https://learn.co/lessons/#{id}"
end