Class: Tumblargh::Node::BlockStart

Inherits:
Base
  • Object
show all
Defined in:
lib/tumblargh/node/block_start.rb

Instance Method Summary collapse

Methods inherited from Base

#to_s, #type

Instance Method Details

#matching_endObject



24
25
26
# File 'lib/tumblargh/node/block_start.rb', line 24

def matching_end
  "{/block:#{name}}"
end

#nameObject



5
6
7
8
# File 'lib/tumblargh/node/block_start.rb', line 5

def name
  str = elements[1].text_value
  "#{str[0].upcase}#{str[1..str.size]}"
end

#optionsObject



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/tumblargh/node/block_start.rb', line 10

def options
  arguments = elements[3]
  return {} if arguments.nil? || arguments.elements.nil?

  arguments.elements.inject({}) do |memo, node|
    nodes = node.elements.first.elements
    k = nodes[0].text_value
    v = nodes[3].text_value

    memo[k] = v
    memo
  end
end

#to_treeObject



28
29
30
# File 'lib/tumblargh/node/block_start.rb', line 28

def to_tree
  return [type, name, options]
end