Class: TutorialList
- Inherits:
-
Object
- Object
- TutorialList
- Defined in:
- lib/nexmo_developer/app/services/tutorial_list.rb
Class Method Summary collapse
Class Method Details
.all ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/nexmo_developer/app/services/tutorial_list.rb', line 31 def self.all tasks = [] # TODO: make this work with I18n fallback Dir.glob("#{Rails.configuration.docs_base_path}/config/tutorials/#{I18n.default_locale}/*.yml") do |path| tasks.push(TutorialListItem.new(path)) end tasks end |
.by_product(product) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/nexmo_developer/app/services/tutorial_list.rb', line 2 def self.by_product(product) { 'tutorials' => tasks_for_product(product), 'use_cases' => Nexmo::Markdown::UseCase.by_product(product).map do |t| { root: t.root, path: t.document_path.to_s, title: t.title, product: product, is_file?: true, is_tutorial?: true, } end, } end |
.tasks_for_product(product) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/nexmo_developer/app/services/tutorial_list.rb', line 19 def self.tasks_for_product(product) tasks = Hash.new { |h, k| h[k] = [] } all.each do |t| t.products.each do |p| t.product = p tasks[p].push(t) end end tasks[product] end |