Class: GuidedPath::MultimediaNode
- Defined in:
- lib/guided_path/multimedia_node.rb
Constant Summary collapse
- CATEGORIES =
%w{image youtube}
Instance Attribute Summary collapse
-
#caption ⇒ Object
readonly
Returns the value of attribute caption.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Attributes inherited from Node
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ MultimediaNode
constructor
A new instance of MultimediaNode.
- #to_hash ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ MultimediaNode
Returns a new instance of MultimediaNode.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/guided_path/multimedia_node.rb', line 10 def initialize(args = {}) super args = args.symbolize_keys raise(ArgumentError, "Must specify a value for the node") unless args[:url] @url = args[:url].to_s raise(ArgumentError, "Must specify a source") unless args[:url] @source = args[:source].to_s raise(ArgumentError, "Must specify a source in #{CATEGORIES.join(', ')}") unless CATEGORIES.include?(@source) @caption = args[:caption] if @caption.kind_of?(String) @caption = {text: @caption, position: 'bottom'} elsif @caption.kind_of?(Hash) @caption = {text: @caption['text'], position: @caption['position'] || 'top'} end end |
Instance Attribute Details
#caption ⇒ Object (readonly)
Returns the value of attribute caption.
8 9 10 |
# File 'lib/guided_path/multimedia_node.rb', line 8 def @caption end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
8 9 10 |
# File 'lib/guided_path/multimedia_node.rb', line 8 def source @source end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
8 9 10 |
# File 'lib/guided_path/multimedia_node.rb', line 8 def url @url end |
Instance Method Details
#to_hash ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/guided_path/multimedia_node.rb', line 29 def to_hash output = super output[:type] = @source output[:url] = @url output[:caption] = @caption output end |