Sha256: 746684b3825c60486e93e0b512a8f93d55c28c54d533198be4a075c894f3fdfe

Contents?: true

Size: 1.85 KB

Versions: 23

Compression:

Stored size: 1.85 KB

Contents

# Copyright, 2020, by Samuel G. D. Williams. <http://www.codeotaku.com>
# 
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# 
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

require_relative 'definition'

module Decode
	module Language
		module Ruby
			# A Ruby-specific block which might carry other definitions.
			class Call < Definition
				# A block can sometimes be a container for other definitions.
				def container?
					false
				end
				
				# The short form of the class.
				# e.g. `foo`.
				def short_form
					@name.to_s
				end
				
				# The long form of the class.
				# e.g. `foo(:bar)`.
				def long_form
					if @node.location.line == @node.location.last_line
						@node.location.expression.source
					else
						self.short_form
					end
				end
				
				# The fully qualified name of the block.
				# e.g. `class ::Barnyard::Dog`.
				def qualified_form
					self.qualified_name
				end
			end
		end
	end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
decode-0.18.5 lib/decode/language/ruby/call.rb
decode-0.18.4 lib/decode/language/ruby/call.rb
decode-0.18.3 lib/decode/language/ruby/call.rb
decode-0.18.2 lib/decode/language/ruby/call.rb
decode-0.18.1 lib/decode/language/ruby/call.rb
decode-0.18.0 lib/decode/language/ruby/call.rb
decode-0.17.3 lib/decode/language/ruby/call.rb
decode-0.17.2 lib/decode/language/ruby/call.rb
decode-0.17.1 lib/decode/language/ruby/call.rb
decode-0.17.0 lib/decode/language/ruby/call.rb
decode-0.16.0 lib/decode/language/ruby/call.rb
decode-0.15.4 lib/decode/language/ruby/call.rb
decode-0.15.3 lib/decode/language/ruby/call.rb
decode-0.15.2 lib/decode/language/ruby/call.rb
decode-0.15.1 lib/decode/language/ruby/call.rb
decode-0.15.0 lib/decode/language/ruby/call.rb
decode-0.14.1 lib/decode/language/ruby/call.rb
decode-0.14.0 lib/decode/language/ruby/call.rb
decode-0.13.0 lib/decode/language/ruby/call.rb
decode-0.12.0 lib/decode/language/ruby/call.rb