Class: ConvertInline

Inherits:
Object
  • Object
show all
Defined in:
lib/convert_inline.rb

Defined Under Namespace

Classes: Error

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node, args = {}) ⇒ ConvertInline

Returns a new instance of ConvertInline.



7
8
9
10
11
12
# File 'lib/convert_inline.rb', line 7

def initialize(node, args = {})
  @node       = node
  @insert     = @node['insert']
  @attributes = @node['attributes']
  @args       = args
end

Instance Attribute Details

#argsObject

Your code goes here…



5
6
7
# File 'lib/convert_inline.rb', line 5

def args
  @args
end

#attributesObject

Your code goes here…



5
6
7
# File 'lib/convert_inline.rb', line 5

def attributes
  @attributes
end

#insertObject

Your code goes here…



5
6
7
# File 'lib/convert_inline.rb', line 5

def insert
  @insert
end

#nodeObject

Your code goes here…



5
6
7
# File 'lib/convert_inline.rb', line 5

def node
  @node
end

Instance Method Details

#convertObject



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/convert_inline.rb', line 14

def convert
  return @insert if @insert.is_a?(String) && @attributes.nil?

  if @insert.is_a?(String)
    @attributes.each_key { |attr| @insert = send(attr) }
  else
    @insert = @insert.keys.first == 'wk-image' ? image : embed(@insert.keys.first)
  end

  @insert
rescue NoMethodError
  @insert
end