Class: OpenStax::Content::Fragment
- Inherits:
-
Object
- Object
- OpenStax::Content::Fragment
- Defined in:
- lib/openstax/content/fragment.rb
Overview
All fragment subclasses must be serializable with to_yaml and YAML.load Nokogiri nodes are not serializable, so they must be processed in the initialize method
Defined Under Namespace
Classes: Embedded, Exercise, Html, Interactive, OptionalExercise, Reading, Video
Instance Attribute Summary collapse
-
#labels ⇒ Object
readonly
Returns the value of attribute labels.
-
#node_id ⇒ Object
readonly
Returns the value of attribute node_id.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #blank? ⇒ Boolean
- #html? ⇒ Boolean
-
#initialize(node:, title: nil, labels: nil) ⇒ Fragment
constructor
A new instance of Fragment.
Constructor Details
#initialize(node:, title: nil, labels: nil) ⇒ Fragment
Returns a new instance of Fragment.
6 7 8 9 10 |
# File 'lib/openstax/content/fragment.rb', line 6 def initialize(node:, title: nil, labels: nil) @title = title @labels = labels || [] @node_id = node[:id] end |
Instance Attribute Details
#labels ⇒ Object (readonly)
Returns the value of attribute labels.
4 5 6 |
# File 'lib/openstax/content/fragment.rb', line 4 def labels @labels end |
#node_id ⇒ Object (readonly)
Returns the value of attribute node_id.
4 5 6 |
# File 'lib/openstax/content/fragment.rb', line 4 def node_id @node_id end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
4 5 6 |
# File 'lib/openstax/content/fragment.rb', line 4 def title @title end |
Instance Method Details
#blank? ⇒ Boolean
12 13 14 |
# File 'lib/openstax/content/fragment.rb', line 12 def blank? false end |
#html? ⇒ Boolean
16 17 18 |
# File 'lib/openstax/content/fragment.rb', line 16 def html? false end |