Class: LearnOpen::Opener
- Inherits:
-
Object
- Object
- LearnOpen::Opener
- Defined in:
- lib/learn_open/opener.rb
Instance Attribute Summary collapse
-
#clone_only ⇒ Object
readonly
Returns the value of attribute clone_only.
-
#editor ⇒ Object
readonly
Returns the value of attribute editor.
-
#get_next_lesson ⇒ Object
readonly
Returns the value of attribute get_next_lesson.
-
#io ⇒ Object
readonly
Returns the value of attribute io.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#target_lesson ⇒ Object
readonly
Returns the value of attribute target_lesson.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(target_lesson, editor, get_next_lesson, clone_only, options = {}) ⇒ Opener
constructor
A new instance of Opener.
- #run ⇒ Object
Constructor Details
#initialize(target_lesson, editor, get_next_lesson, clone_only, options = {}) ⇒ Opener
Returns a new instance of Opener.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/learn_open/opener.rb', line 15 def initialize(target_lesson, editor, get_next_lesson, clone_only, = {}) @target_lesson = target_lesson @editor = editor @get_next_lesson = get_next_lesson @clone_only = clone_only @io = .fetch(:io, LearnOpen.default_io) @logger = .fetch(:logger, LearnOpen.logger) @options = end |
Instance Attribute Details
#clone_only ⇒ Object (readonly)
Returns the value of attribute clone_only.
3 4 5 |
# File 'lib/learn_open/opener.rb', line 3 def clone_only @clone_only end |
#editor ⇒ Object (readonly)
Returns the value of attribute editor.
3 4 5 |
# File 'lib/learn_open/opener.rb', line 3 def editor @editor end |
#get_next_lesson ⇒ Object (readonly)
Returns the value of attribute get_next_lesson.
3 4 5 |
# File 'lib/learn_open/opener.rb', line 3 def get_next_lesson @get_next_lesson end |
#io ⇒ Object (readonly)
Returns the value of attribute io.
3 4 5 |
# File 'lib/learn_open/opener.rb', line 3 def io @io end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
3 4 5 |
# File 'lib/learn_open/opener.rb', line 3 def logger @logger end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/learn_open/opener.rb', line 3 def @options end |
#target_lesson ⇒ Object (readonly)
Returns the value of attribute target_lesson.
3 4 5 |
# File 'lib/learn_open/opener.rb', line 3 def target_lesson @target_lesson end |
Class Method Details
.run(lesson:, editor_specified:, get_next_lesson:, clone_only:) ⇒ Object
11 12 13 |
# File 'lib/learn_open/opener.rb', line 11 def self.run(lesson:, editor_specified:, get_next_lesson:, clone_only:) new(lesson, editor_specified, get_next_lesson, clone_only).run end |
Instance Method Details
#run ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/learn_open/opener.rb', line 27 def run logger.log('Getting lesson...') io.puts "Looking for lesson..." lesson_data = LearnOpen::Adapters::LearnWebAdapter .new() .fetch_lesson_data( target_lesson: target_lesson, fetch_next_lesson: get_next_lesson ) lesson = Lessons.classify(lesson_data, ) environment = LearnOpen::Environments.classify() lesson.open(environment, editor, clone_only) end |