Class: Coradoc::Element::Video

Inherits:
Object
  • Object
show all
Defined in:
lib/coradoc/element/video.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title, options = {}) ⇒ Video

Returns a new instance of Video.



6
7
8
9
10
11
12
13
# File 'lib/coradoc/element/video.rb', line 6

def initialize(title, options = {})
  @title = title
  @id = options.fetch(:id, nil)
  @anchor = @id.nil? ? nil : Inline::Anchor.new(@id)
  @src = options.fetch(:src, '')
  @attributes = options.fetch(:attributes, [])
  # @attributes.add_valid_named('opts')
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/coradoc/element/video.rb', line 4

def id
  @id
end

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/coradoc/element/video.rb', line 4

def options
  @options
end

#srcObject (readonly)

Returns the value of attribute src.



4
5
6
# File 'lib/coradoc/element/video.rb', line 4

def src
  @src
end

#titleObject (readonly)

Returns the value of attribute title.



4
5
6
# File 'lib/coradoc/element/video.rb', line 4

def title
  @title
end

Instance Method Details

#to_adocObject



15
16
17
18
19
20
# File 'lib/coradoc/element/video.rb', line 15

def to_adoc
  anchor = @anchor.nil? ? "" : "#{@anchor.to_adoc}\n"
  title = ".#{@title}\n" unless @title.empty?
  attrs = @attributes.empty? ? "\[\]" : @attributes.to_adoc
  [anchor, title, "video::", @src, attrs].join("")
end