Class: YardAstEditable::Fcall

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ Fcall

Returns a new instance of Fcall.



8
9
10
# File 'lib/yard_ast_editable.rb', line 8

def initialize(node)
  @node = node
end

Instance Attribute Details

#nodeObject (readonly)

Returns the value of attribute node.



7
8
9
# File 'lib/yard_ast_editable.rb', line 7

def node
  @node
end

Instance Method Details

#argumentsObject



20
21
22
23
24
25
26
# File 'lib/yard_ast_editable.rb', line 20

def arguments
  return @arguments if @arguments
  n = @node[1]
  @arguments = (n.type == :arg_paren ? n[0] : n) || []
  @arguments.pop if @arguments.last == false
  @arguments
end

#blockObject



16
17
18
# File 'lib/yard_ast_editable.rb', line 16

def block
  @node[2]
end

#block_content_sourceObject



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/yard_ast_editable.rb', line 28

def block_content_source
  return nil unless block
  result = block.source
  case block.type
  when :do_block then
    result.sub!(/\Ado[ \t\f]*(\|.*?\|)?\n?/, '')
    result.sub!(/end[\s\n]*\Z/, '')
  when :brace_block then
    result.sub!(/^\{\s*(\|.*?\|)?\n?/, '')
    result.sub!(/\}[\s\n]*\Z/, '')
  end
  result
end

#nameObject



12
13
14
# File 'lib/yard_ast_editable.rb', line 12

def name
  @node[0].source
end