DecodeSourceDecodeLanguageRubyBlock

class Block

A Ruby-specific block which might carry other definitions.

Definitions

def container?

A block can sometimes be a container for other definitions.

Implementation

def container?
	true
end

def nested_name

Generate a nested name for the block.

Implementation

def nested_name
	".#{name}"
end

def short_form

The short form of the block. e.g. foo.

Implementation

def short_form
	@name.to_s
end

def long_form

The long form of the block. e.g. foo(:bar).

Implementation

def long_form
	if @node.location.line == @node.location.last_line
		@node.location.expression.source
	else
		@node.children[0].location.expression.source
	end
end

def qualified_form

The fully qualified name of the block. e.g. ::Barnyard::foo.

Implementation

def qualified_form
	self.qualified_name
end

def convert(kind)

Convert the block to a different kind of definition.

Signature

parameter kind Symbol

The kind to convert to.

Implementation

def convert(kind)
	case kind
	when :attribute
		Attribute.new(@node, @name,
			comments: @comments, parent: @parent, language: @language
		)
	else
		super
	end
end