Sha256: eec9048d86e0668eb09e15d452fa96d4f2dbc439455ed471c07d3f07388e0039
Contents?: true
Size: 1.15 KB
Versions: 94
Compression:
Stored size: 1.15 KB
Contents
class Tutorial::Metadata attr_reader :name, :file_loader delegate :path, :yaml, to: :file_loader def initialize(name:) @name = name @file_loader = load_file! end def products @products ||= yaml['products'] || [] end def title @title ||= yaml['title'] end def description @description ||= yaml['description'] end def external_link @external_link ||= yaml['external_link'] end def available_code_languages @available_code_languages ||= begin Nexmo::Markdown::DocFinder .code_languages_for_tutorial(path: path.sub('.yml', '/')) .map { |file_path| File.basename(Pathname.new(file_path).basename, '.yml') } .sort_by { |l| Nexmo::Markdown::CodeLanguage.find(l).weight } end end def code_language @code_language ||= begin available_code_languages .min_by { |k| Nexmo::Markdown::CodeLanguage.languages.map(&:key).index(k) } end end def default_product @default_product ||= products.first end def load_file! Tutorial::FileLoader.new( root: Tutorial.tutorials_path, code_language: nil, doc_name: @name ) end end
Version data entries
94 entries across 94 versions & 1 rubygems