Class: YardAstEditable::Fcall
- Inherits:
-
Object
- Object
- YardAstEditable::Fcall
- Defined in:
- lib/yard_ast_editable.rb
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
Returns the value of attribute node.
Instance Method Summary collapse
- #arguments ⇒ Object
- #block ⇒ Object
- #block_content_source ⇒ Object
-
#initialize(node) ⇒ Fcall
constructor
A new instance of Fcall.
- #name ⇒ Object
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
#node ⇒ Object (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
#arguments ⇒ Object
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 |
#block ⇒ Object
16 17 18 |
# File 'lib/yard_ast_editable.rb', line 16 def block @node[2] end |
#block_content_source ⇒ Object
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 |
#name ⇒ Object
12 13 14 |
# File 'lib/yard_ast_editable.rb', line 12 def name @node[0].source end |