Class: Fasterer::MethodDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/fasterer/method_definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(element) ⇒ MethodDefinition

Returns a new instance of MethodDefinition.



11
12
13
14
15
16
17
# File 'lib/fasterer/method_definition.rb', line 11

def initialize(element)
  @element = element # Ripper element
  set_method_name
  set_body
  set_arguments
  set_block_argument_name
end

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



7
8
9
# File 'lib/fasterer/method_definition.rb', line 7

def arguments
  @arguments
end

#block_argument_nameObject (readonly)

Returns the value of attribute block_argument_name.



5
6
7
# File 'lib/fasterer/method_definition.rb', line 5

def block_argument_name
  @block_argument_name
end

#bodyObject (readonly)

Returns the value of attribute body.



6
7
8
# File 'lib/fasterer/method_definition.rb', line 6

def body
  @body
end

#elementObject (readonly)

for testing purposes



3
4
5
# File 'lib/fasterer/method_definition.rb', line 3

def element
  @element
end

#method_nameObject (readonly) Also known as: name

Returns the value of attribute method_name.



4
5
6
# File 'lib/fasterer/method_definition.rb', line 4

def method_name
  @method_name
end

Instance Method Details

#has_block?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/fasterer/method_definition.rb', line 19

def has_block?
  !!@block_argument_name
end

#setter?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/fasterer/method_definition.rb', line 23

def setter?
  name.to_s.end_with?('=')
end