Class: Ssource::Source::Method

Inherits:
Element
  • Object
show all
Defined in:
lib/ssource/source/method.rb

Instance Attribute Summary

Attributes inherited from Element

#accessibility, #body_length, #body_offset, #elements, #kind, #length, #name, #name_length, #name_offset, #offset

Instance Method Summary collapse

Methods inherited from Element

#display_name

Constructor Details

#initialize(json) ⇒ Method

Returns a new instance of Method.



4
5
6
# File 'lib/ssource/source/method.rb', line 4

def initialize(json)
  super
end

Instance Method Details

#class?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/ssource/source/method.rb', line 12

def class?
  kind.end_with? 'class'
end

#instance?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/ssource/source/method.rb', line 8

def instance?
  kind.end_with? 'instance'
end

#parametersObject



20
21
22
# File 'lib/ssource/source/method.rb', line 20

def parameters
  elements.select { |element| element.is_a? Variable }
end

#pretty_printObject



30
31
32
# File 'lib/ssource/source/method.rb', line 30

def pretty_print
  display_name
end

#static?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/ssource/source/method.rb', line 16

def static?
  kind.end_with? 'static'
end

#to_hashObject



24
25
26
27
28
# File 'lib/ssource/source/method.rb', line 24

def to_hash
  hash = super
  hash[:parameters] = parameters.map(&:to_hash) unless parameters.empty?
  hash
end