Class: OpenStax::Content::Fragment

Inherits:
Object
  • Object
show all
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

Direct Known Subclasses

Exercise, Html

Defined Under Namespace

Classes: Embedded, Exercise, Html, Interactive, OptionalExercise, Reading, Video

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#labelsObject (readonly)

Returns the value of attribute labels.



4
5
6
# File 'lib/openstax/content/fragment.rb', line 4

def labels
  @labels
end

#node_idObject (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

#titleObject (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

Returns:

  • (Boolean)


12
13
14
# File 'lib/openstax/content/fragment.rb', line 12

def blank?
  false
end

#html?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/openstax/content/fragment.rb', line 16

def html?
  false
end