Module: Scorm2004::Manifest::VisitorPattern
- Included in:
- AdlseqMapInfo, AdlseqObjective, AdlseqObjectives, CompletionThreshold, ConditionRule, ConstrainedChoiceConsiderations, ControlMode, Data, DataFromLms, DeliveryControls, Dependency, File, HideLmsui, Item, LimitConditions, Manifest, Map, MapInfo, MinNormalizedMeasure, NavigationInterface, Objective, Objectives, Organization, Organizations, Presentation, PrimaryObjective, RandomizationControls, Resource, Resources, RollupAction, RollupCondition, RollupConditions, RollupConsiderations, RollupRule, RollupRules, RuleAction, RuleCondition, RuleConditions, Schema, Schemaversion, Sequencing, SequencingCollection, SequencingRules, TimeLimitAction, Title
- Defined in:
- lib/scorm2004/manifest/visitor_pattern.rb
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(options = {}) ⇒ Object
-
#metadata ⇒ Nokogiri::XML::Node?
The <metadata> element or
nil
. - #to_hash ⇒ Object
- #visit(el) ⇒ Object
Class Method Details
Instance Method Details
#initialize(options = {}) ⇒ Object
10 11 12 |
# File 'lib/scorm2004/manifest/visitor_pattern.rb', line 10 def initialize( = {}) @options = end |
#metadata ⇒ Nokogiri::XML::Node?
Returns The <metadata> element or nil
.
35 36 37 |
# File 'lib/scorm2004/manifest/visitor_pattern.rb', line 35 def @el.at('./imscp:metadata', NS) end |
#to_hash ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/scorm2004/manifest/visitor_pattern.rb', line 23 def to_hash if respond_to? :content content else {}.merge(self.class.respond_to?(:attributes) ? attributes_hash : {}) .merge(self.class.respond_to?(:children) ? children_hash : {}) .merge(respond_to?(:href) ? {:href => href } : {}) .reject { |k, v| v.nil? || v == [] || v == {} } end end |
#visit(el) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/scorm2004/manifest/visitor_pattern.rb', line 14 def visit(el) @el = el check_attributes if self.class.respond_to?(:attributes) do_visit if self.respond_to?(:do_visit, true) visit_children if self.class.respond_to?(:children) post_visit if self.respond_to?(:post_visit, true) self end |