Sha256: f0e076b7bcf32943e315cae0e637e3e59a8f56a3357b536567745689c7ec83f9
Contents?: true
Size: 733 Bytes
Versions: 4
Compression:
Stored size: 733 Bytes
Contents
# frozen_string_literal: true require 'hs/loaders/xml_parser' module HS module CourseLoader include HS::XMLParser def load_course(xml, &block) create_course(parse_xml(xml), &block) end private def create_course(data) # rubocop:disable Metrics/MethodLength course = HS::Course.new(slug: data[:slug]) data[:_children].each do |child| case child[:_name] when :title course.title = get_text(child) when :chapters if block_given? files = child[:_children].map { |c| c[:file] }.compact files.each do |file| yield course, file end end end end course end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
hs-cli-0.2.2 | lib/hs/loaders/course_loader.rb |
hs-cli-0.2.1 | lib/hs/loaders/course_loader.rb |
hs-cli-0.2.0 | lib/hs/loaders/course_loader.rb |
hs-cli-0.1.2 | lib/hs/loaders/course_loader.rb |