class Fasterer::MethodDefinitionArgument

Attributes

element[R]
name[R]
type[R]

Public Class Methods

new(element) click to toggle source
# File lib/fasterer/method_definition.rb, line 61
def initialize(element)
  @element = element
  set_name
  set_argument_type
end

Public Instance Methods

default_argument?() click to toggle source
# File lib/fasterer/method_definition.rb, line 71
def default_argument?
  @type == :default_argument
end
keyword_argument?() click to toggle source
# File lib/fasterer/method_definition.rb, line 75
def keyword_argument?
  @type == :keyword_argument
end
regular_argument?() click to toggle source
# File lib/fasterer/method_definition.rb, line 67
def regular_argument?
  @type == :regular_argument
end

Private Instance Methods

set_argument_type() click to toggle source
# File lib/fasterer/method_definition.rb, line 85
def set_argument_type
  @type = if element.is_a?(Symbol)
            :regular_argument
          elsif element.is_a?(Sexp) && element.sexp_type == :lasgn
            :default_argument
          elsif element.is_a?(Sexp) && element.sexp_type == :kwarg
            :keyword_argument
  end
end
set_name() click to toggle source
# File lib/fasterer/method_definition.rb, line 81
def set_name
  @name = element.is_a?(Symbol) ? element : element[1]
end