Class: Decode::Language::Ruby::Attribute

Inherits:
Definition
  • Object
show all
Defined in:
lib/decode/language/ruby/attribute.rb

Overview

A Ruby-specific attribute.

Instance Attribute Summary

Attributes inherited from Definition

#comments, #language, #name, #parent

Instance Method Summary collapse

Methods inherited from Definition

#container?, #convert, #documentation, #initialize, #inspect, #location, #multiline?, #nested?, #nested_name, #path, #path_name, #qualified_form, #qualified_name, #start_with?, #text

Constructor Details

This class inherits a constructor from Decode::Definition

Instance Method Details

#long_formObject



24
25
26
27
28
29
30
# File 'lib/decode/language/ruby/attribute.rb', line 24

def long_form
	if @node.location.line == @node.location.last_line
		@node.location.expression.source
	else
		short_form
	end
end

#short_formObject

The short form of the attribute. e.g. ‘attr :value`.



15
16
17
18
19
20
21
22
# File 'lib/decode/language/ruby/attribute.rb', line 15

def short_form
	case @node.type
	when :block
		"#{@name} { ... }"
	else
		@node.location.expression.source
	end
end