Method: OpenStax::Content::Fragment::Exercise#initialize
- Defined in:
- lib/openstax/content/fragment/exercise.rb
#initialize(node:, title: nil, labels: []) ⇒ Exercise
Returns a new instance of Exercise.
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/openstax/content/fragment/exercise.rb', line 41 def initialize(node:, title: nil, labels: []) super @embed_queries = node.css(ABSOLUTIZED_EMBED_URL_CSS).map do |anchor| url = anchor.attribute('href').value match = ABSOLUTIZED_EMBED_URL_REGEX.match(url) next if match.nil? [ match[1].to_sym, URI.decode_www_form_component(match[2]) ] end.compact end |